LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (June 1997, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 19 Jun 1997 15:31:10 GMT
Reply-To:     Clark Roberts <dacmr@MINDSPRING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Clark Roberts <dacmr@MINDSPRING.COM>
Organization: Decision Analytics
Subject:      Re: dde
Content-Type: text/plain; charset=us-ascii

I use the following macro code (portion of a larger macro) to first close MS Word if it's open, allowing the user to save any work, then reopen Word as a DDE session. It's not perfect, but in a semi controlled environment it works OK. The portion that tests to see if Word is open uses SCL function calls through the %SYSFUNC macro function and it runs fine under 6.12. I did have some problems under 6.11 TS040 when Word was not open. The function call returned a missing value and %SYSFUNC couldn't deal with it. But %SYSFUNC was not production in 6.11.

_______________________________________________________________________________ __________

*************************************************************** *** *** If MS Word is already open, then close it and allow the user *** to save their work. *** *************************************************************** ;;;

filename wordchk dde 'winword|system!selected' command;

%let status = %sysfunc(fopen(wordchk,S));

%if &status %then %do; data _null_; file wordchk; put '[FileExit 1]'; run; %let rc = %sysfunc(fclose(&status)); filename wordchk clear; %end;

************************************************************** *** Start a MS Word session if requested. SAS calls to the *** Windows API are used to find the location of MS Word and *** if found, starts a session. The modtabl.txt file, which *** contains the parameters for each system call and the *** system.doc file, which is used as a trigger for the *** FindExecutableA API function to locate MS Word on the system. *** The assumption is that .DOC files are associated with MS *** Word documents. If this is false then the macro will *** not work properly. A better, but more complicated approach *** under WIN95 would be to access the Registry to get this *** information. Another less eloquent approach is to just *** pass the location of MS Word as a parameter to the *** macro. *** *** The SAS MODULEN function is used for the API interface. *** If MS Word fails to open, then set the RCWORD return code *** to 0, If everything functions properly, then the MS *** Word session is started in a minimized state. ************************************************************** ;;;

filename sascbtbl "&rootdir.system\modtabl.txt";

data _null_; length sysdir wordpath $200; wordpath = ''; sysdir = "&rootdir.system"; rc1 = modulen('*ei','FindExecutableA','system.doc',sysdir,wordpath); if rc1 > 32 then do; rc2 = modulen('*ei','WinExec',wordpath,2); if rc2 <= 0 then call symput('rcword','0'); end; else do; put 'OPENWORD ERROR: Could not find the MS Word executable'; call symput('rcword','0'); end; put rc1= rc2= wordpath=; run;

filename sascbtbl clear;

filename wordsys dde 'Winword|System';

_______________________________________________________________________________

This is the MODTABL.TXT file referenced in the above SAS macro

routine WinExec maxarg=2 minarg=2 stackpop=called module=KERNEL32 returns=ushort; arg 1 input char format=$cstr200.; arg 2 input num byvalue format=pib4.;

routine FindExecutableA maxarg=3 minarg=3 stackpop=called module=shell32 returns=ushort; arg 1 input char format=$cstr200.; arg 2 input char format=$cstr200.; arg 3 output char format=$cstr200.;

______________________________________________________________________

On Wed, 18 Jun 1997 15:01:03 +0200, Mikal Ustad <mikal@ism.uit.no> wrote:

>Is it possible in SCL to verify if a windows application(Word/Excel) >is running (or not) before i execute the statement: > options noxwait >noxsync; X >"i:\msoffice\winword\winword" ; ?? > filename dok1 dde 'winword|dokument1' command; > . > . > >Mikal

Clark Roberts Decision Analytics e-Mail dacmr@mindspring.com Voice/Message/Fax: (619) 565-9627 Voice Mail Pager: (619) 975-0758


Back to: Top of message | Previous page | Main SAS-L page