Help using Base SAS procedures

How to open Excel at background(invisible)

Reply
Regular Contributor
Posts: 222

How to open Excel at background(invisible)

Hello everyone,

I know we can use SAS x command to open outside file or application such as Excel using code 1 as follow:

Also we can use another method to open excel :see code 2

My question is Could we open Excel in background? I mean open excel at invisible status,,,if this is not available,,, open  excel at its minimized window status will be another alternative solution.

Because I don't want the opened excel appear and cover our SAS console.

Thanks

Mike

code1:

options noxwait noxsync;

x '"C:\Program Files\Microsoft Office\Office12\EXCEL"';

code 2:

OPTIONS NOXWAIT NOXSYNC;

DATA _NULL_;

RC=SYSTEM('START EXCEL');

RC=SLEEP(3);

RUN;

PROC Star
Posts: 7,467

Re: How to use x command open Excel at background(invisible)

Posted in reply to Mike_Davis

      PUT '[app.minimize()]';

Regular Contributor
Posts: 222

Re: How to use x command open Excel at background(invisible)

Thank you Art,

The PUT function works well to minimize  a new opened excel file.
but how to minimize Excel console before opened an excel file?

because if we want to open a excel file ,at first we should open Excel console firstly use one of  the following SAS codes:


options noxwait noxsync;

x '"C:\Program Files\Microsoft Office\Office12\EXCEL"';

or:

OPTIONS NOXWAIT NOXSYNC;
DATA _NULL_;
RC=SYSTEM('START EXCEL');
RC=SLEEP(5);
RUN;


what I want to minimize firstly is the Excel console.

Thank you!

Mike

PROC Star
Posts: 7,467

Re: How to use x command open Excel at background(invisible)

Posted in reply to Mike_Davis

Mike,

Once you get a solution mark the thread as being answered.

Given what you want to do, forget my previous advice of using app.minimize()

The answer is a bit convoluted, but works.

First, create a special shortcut for Excel.  I did that by going to where Excel was located on my computer, right clicked on it, and then clicked on create shortcut.

I then created a folder, under Office11 (which I named test) and then dragged the shortcut to that folder.

Then I right clicked on the shortcut and renamed it to be excel.  Then (still within properties) I set the value of run to be minimized.

After doing that, I changed the SAS code to open that link rather than opening Excel directly.  Having done that, Excel never appeared on the screen, but everything was accomplished.  The code I ran was:

%let pw=abcdefg;

options noxwait noxsync;

x '"C:\Program Files\Microsoft Office\Office11\test\EXCEL.lnk"';

data _null_;

  x=sleep(3);

run;

filename ExcelCmd dde 'Excel|system';

data _null_;

  file ExcelCmd;

  s = '[open(' || quote ("c:\trialdata.xls.") ||",,,,""&pw."")]";

  put s;

run;

Regular Contributor
Posts: 222

Re: How to use x command open Excel at background(invisible)

Thank you Art,

also I found an option works well ,but just for mininize ,can't run at background or invisible:

options noxwait noxsync xmin;

Ask a Question
Discussion stats
  • 4 replies
  • 2310 views
  • 3 likes
  • 2 in conversation