BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6

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;

4 REPLIES 4
art297
Opal | Level 21

      PUT '[app.minimize()]';

Mike_Davis
Fluorite | Level 6

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

art297
Opal | Level 21

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;

Mike_Davis
Fluorite | Level 6

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3927 views
  • 3 likes
  • 2 in conversation