Date: Thu, 28 Aug 2003 22:22:25 -0400
Reply-To: Jim Hoffman <jshoffman@DBSICORP.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Hoffman <jshoffman@DBSICORP.COM>
Subject: DDE Excel Batch Execution Follow Up
Per Howard Schreier suggestion I am posting the code that I have attempted
to execute while the computer is locked. Unlocked it works fine. Locked
gives blank worksheet. Hopefully someone can shed some light on how to get
the same "good" results either way.
-----
%let delay = %sysfunc(sleep(10)); /* Delay to lock computer */
/* Start Excel for following DDE output by SAS */
%macro Start_Excel;
options noxwait noxsync xmin;
filename xl_out dde 'excel|system' notab;
data _null_;
length fid rc start stop time 8;
fid = fopen('xl_out','s');
if (fid le 0) then do;
rc=system('start excel');
start=datetime();
stop=start+10;
do while (fid le 0);
fid = fopen('xl_out','s');
time=datetime();
if (time ge stop) then fid=1;
end;
end;
else put / 'Excel is already running' //;
rc=fclose(fid);
run;
%mend Start_Excel;
%Start_Excel;
/* This program writes data to EXCEL from SAS using DDE */
data _null_;
file xl_out;
put '[error(false)]';
put '[Workbook.activate("Sheet1")]';
put '[Select("R1C5")]';
put 'Test batch run' '09'x;
put '[save.as("c:\Test_Batch_Excel.xls")]';
put '[quit()]';
run;
filename xl_out clear;
-----
Thanks for your help, Jim Hoffman