data cars;set sashelp.cars;run;
%let xlsfile1 = C:\Users\1558977\Desktop\autocreate\cars.xlsx;
proc export outfile="&xlsfile1" data=cars dbms=xlsx replace;
run;
quit;
* This next routine starts the Excel application. *;
filename cmds dde 'excel|system';
x "'C:\Program Files\Microsoft Office\Office11\excel.exe'";
data _null_;
x=sleep(3);
run;
data _null_;
file cmds;
put '[open("'"&xlsfile1"'")]';
run; The intent is to open the excel file and save it password protected. But SAS keeps giving this error:Physical file does not exis, excel|sytem UPDATE: The error is linked to excel.exe file not found. If I have Excel running already, the code works fine. So need to search for that excel.exe. data cars;set sashelp.class;run;
%let xlsfile1 = C:\Users\1558977\Desktop\autocreate\cars.xls;
%let xlsfile2 = C:\Users\1558977\Desktop\autocreate\carspassword.xls;
proc export outfile="&xlsfile1" data=cars dbms=xls replace;
run;
quit;
* This next routine starts the Excel application. *;
filename cmds dde 'excel|system';
data _null_ ;
file cmds;
put '[open("'"&xlsfile1"'")]';
put '[SAVE()]';
put '[Save.as("'"&xlsfile2"'",1,"'"test"'")]';
PUT '[FILE-CLOSE()]';
run; I've amended by deleting the point towards excel.exe. But for this to work, it requires Excel to be opened first.
... View more