LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 1997, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 2 Jan 1997 19:04:41 GMT
Reply-To:     "Allen E. Bingham" <AllenB@FISHGAME.STATE.AK.US>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Allen E. Bingham" <AllenB@FISHGAME.STATE.AK.US>
Organization: Alaska Dept. of Fish & Game
Subject:      Re: DDE
Content-Type: text/plain; charset=ISO-8859-1

lpogoda@aol.com wrote in article <01bbf8da$a7e6cb60$6df53f92@HOST.DOMAIN>... > In article <3.0.16.19961230085924.50f7e7c4@ak.planet.gen.nz>, Mark Bodt > <markbodt@STSS.CO.NZ> writes: > > >Well, DDE should work OK with Win95. I don't have 95 on my machine, so > >can't test it out, but I'm assured by several techos at SAS in Cary that > it > >does work. > > > >The fact that it works sometimes sugests that something is changing in > your > >settings. The only thing that I can think of at the moment is that the > >document name in the DDE triplet is not valid in all cases. For example > if > >your document is called test.doc and is in directory c:\docs then the > >triplet winword|test!bookm1 may work if the default directory for work is > >currently set to c:\docs, but if it is set to something else eg if you > have > >just been working with a document called c:\work\pay\salary.doc then the > >triplet winword|test!bookm1 will fail if that directory does not contain > >the document. > > > >To avoid this you can specify the full document name in the triplet eg: > >winword|c:\docs\test.doc!bookm1 > > > >Don't know if this solves your problem?? > > > > > > Thanks to all those who've responded to my plea for help so far. However, > the responses lead me to think my original statment of the problem was > less than clear. I'm in the office today, so let me repost the problem > with an actual example instead of attempting to do so from memory. > > The task at hand is to write a series of final reports to Microsoft Word.

> I've tried a couple of approaches: > > 1. Write the reports to a flat file. Import the flat file to Word. > 2. Write the reports directly to Word. > > In the first case, the statements required to import a file can be > determined by recording a word macro that imports a file and using the > resulting WordBasic statements as a guide. > > In the second case, the report stream includes characters Word apparently > recoginizes as keystrokes rather than data - for instance, a percent sign > (%) activates the menu bar, halting further output until the menu bar is > manually closed. The report stream is therefore recast as a series of > WordBasic statements. > > In both cases, output is being sent to the "command" level of Word, not > directly to the body of the Word document. > > The sample log that follows is taken from a run under Win95. When run > under Win 3.11, both data steps shown *always* succeed. Under Win95, the > first data step fails most of the time, the second usually, but not > always, succeeds. If the first is omitted, the second usually fails. > Once one attempt succeeds, all subsequent attempts also succeed. I've not > yet had a third attempt succeed when the first two fail. > > In all cases, document1 always exists - I can see it on the screen - and > document TIM is a file I can see using file manager or explorer. > > Any help would be greatly appreciated. > > A sample log: > > 73 x 'winword' > 73 ; > 74 filename doc1 dde 'winword|document1' command; > 75 filename TIM dde 'winword|TIM' command; > 76 data _null_; > 77 file doc1; > 78 put '[Insert "This is a dummy string."]'; > 79 put '[EditSelectAll]'; > 80 put '[EditClear]'; > 81 stop; > 82 run; > > ERROR: Physical file does not exist, winword|document1. > NOTE: The SAS System stopped processing this step because of errors. > NOTE: The DATA statement used 1.42 seconds. > > > 83 data _null_; > 84 file doc1; > 85 put '[ChDefaultDir "\\STATSPXL02\DATA07\INCPREV\WORKFILE\", > 0]'; > 86 put '[FileOpen .Name = "TIM.DOC"]'; > 87 stop; > 88 run; > > ERROR: Physical file does not exist, winword|document1. > NOTE: The SAS System stopped processing this step because of errors. > NOTE: The DATA statement used 6.58 seconds. > > > >

I think I know what your problem is ... you need to make sure you have the SAS system option NOXSYNC set ... and make sure you give Winword enough time to load

See code below (that works on my machine...edited from yours to fit where I have Winword and what files I could open).

Note you may need to edit (increase) the amount of time needed to bring up Winword (the Sleep step below) for this to be "fool proof". ---------------------- options noxsync;

x "C:\Progra~1\MSOffice\Winword\WINWORD.EXE"; ; /* Sleep for 3 seconds to give Winword time to come up. */

data _null_; x=sleep(3); run;

filename doc1 dde 'winword|document1' command; filename afs dde 'winword|afs97-1d' command;

data _null_; file doc1; put '[Insert "This is a dummy string."]'; put '[EditSelectAll]'; put '[EditClear]'; stop; run;

data _null_; file doc1; put '[ChDefaultDir "\windows\desktop\",0]'; put '[FileOpen .Name = "afs97-1d.doc"]'; stop; run; ---------------------- Which resulted in the following log statements from SAS: ---------------------- 82 options noxsync; 83 84 x "C:\Progra~1\MSOffice\Winword\WINWORD.EXE" 84 ; 85 ; 86 /* Sleep for 3 seconds to give Winword time to come up. */ 87 88 data _null_; 89 x=sleep(3); 90 run;

NOTE: The DATA statement used 3.12 seconds.

91 92 filename doc1 dde 'winword|document1' command; 93 filename afs dde 'winword|afs97-1d' command; 94 95 data _null_; 96 file doc1; 97 put '[Insert "This is a dummy string."]'; 98 put '[EditSelectAll]'; 99 put '[EditClear]'; 100 stop; 101 run;

NOTE: The file DOC1 is: FILENAME=winword|document1, RECFM=V,LRECL=256

NOTE: 3 records were written to the file DOC1. The minimum record length was 11. The maximum record length was 34. NOTE: The DATA statement used 10.5 seconds.

102 103 data _null_; 104 file doc1; 105 put '[ChDefaultDir "\windows\desktop\",0]'; 106 put '[FileOpen .Name = "afs97-1d.doc"]'; 107 stop; 108 run;

NOTE: The file DOC1 is: FILENAME=winword|document1, RECFM=V,LRECL=256

NOTE: 2 records were written to the file DOC1. The minimum record length was 33. The maximum record length was 36. NOTE: The DATA statement used 3.29 seconds. ---------------------- BTW-I've been interested in using DDE with Word for a couple of years ... but have been frustrated in not being able to figure out the DDE triplet for Word...this will really help ... excepting for the fact that I'm unfamiliar with WordBasic...at least I now know that this is possible!!!

Thanks. -- Allen E. Bingham, Biometrician Alaska Department of Fish and Game Opinions are my own not ADF&G

E-mail: AllenB@fishgame.state.ak.us


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