Hello,
I would like to execute an Excel VBA using SAS EG 8.3. Excel is hosted on my c drive while the Excel file itself is hosted on a window server. SAS .
Here's my sript , follow by the log file.
options noxwait noxsync;
x '"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" ';
/* Sleep for 5 seconds to give Excel time to come up */
data _null_;
x=sleep(5);
run;
filename cmds dde "excel|system";
data _null_;
file cmds;
/* Open the excel file test.xlsm which contains the VBA macro */
put '[open("P:\Temp\TestStephane.xlsm")]';
/* Run myVBAmacro */
put '[run("TestStephane.xlsm!genereGus")]';
run;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
28
29 options noxwait noxsync;
_______
13
ERROR 13-12: Unrecognized SAS option name NOXWAIT.
29 ! options noxwait noxsync;
_______
13
ERROR 13-12: Unrecognized SAS option name NOXSYNC.
30 x '"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" '
30 ! ;
31 /* Sleep for 5 seconds to give Excel time to come up */
32 data _null_;
33 x=sleep(5);
34 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
35 filename cmds dde "excel|system";
ERROR: Invalid device type.
ERROR: Error in the FILENAME statement.
36
37 data _null_;
38 file cmds;
39 /* Open the excel file test.xlsm which contains the VBA macro */
2 The SAS System 09:11 Thursday, April 20, 2023
40 put '[open("P:\Temp\TestStephane.xlsm")]';
41 /* Run myVBAmacro */
42 put '[run("TestStephane.xlsm!genereGus")]';
43 run;
ERROR: Insufficient authorization to access /opt/sas94/Config/Lev1/SASApp/cmds.dat.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
***********
One more question. How do you close the excel file ? Does this command will work ?
put '[close("P:\Temp\TestStephane.xlsm")]';
you are trying to to run local excel
"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
on remote SAS server:
/opt/sas94/Config/Lev1/SASApp/
no way it will happen...
Bart
you are trying to to run local excel
"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
on remote SAS server:
/opt/sas94/Config/Lev1/SASApp/
no way it will happen...
Bart
Hello @alepage
In order to run excel vba using SAS EG is that SAS Should be installed on a Windows machine and excel should be installed on the same machine and users have the necessary permissions.
From the log it appears that SAS is running on a Linux/Unix server. So what you want is not a feasible preposition.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.