Date: Wed, 30 Jul 2008 19:12:45 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: DDE Excel problem -- dealing with multiple Excel sessions
Couldn't you avoid the clash by simply specifying which workbook you were
trying to access, rather than 'excel|system'? See, e.g.,
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0110E&L=sas-l&D=0&P=23431
HTH,
Art
---------
On Wed, 30 Jul 2008 14:49:19 -0700, mischman <mischman@GMAIL.COM> wrote:
>Everything works great unless there happens to be another instance of
>Excel running, in which case everything turns into chaos. I use a
>standard DDE routine to open an Excel session (see below). The
>problems occur when I try to write to Excel further on down in the
>program -- I end up writing results to the wrong Excel session, or
>worse. Any suggestions?
>
>%macro openExcel();
> options noxsync noxwait;
> filename sas2xl dde 'excel|system'; * reference to open/close
>excel ;
> data _null_;
> length fid rc start stop time 8;
> fid=fopen('sas2xl','s');
> if (fid le 0) then do;
> rc=system('start excel');
> start=datetime();
> stop=start+10;
> do while (fid le 0);
> fid=fopen('sas2xl','s');
> time=datetime();
> if (time ge stop) then fid=1;
> end;
> end;
> rc=fclose(fid);
> run;
>%mend openExcel;
|