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 (August 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 24 Aug 2008 07:39:59 -0400
Reply-To:     Nathaniel.Wooding@DOM.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject:      Re: SAS issuing print command to Word
In-Reply-To:  <>
Content-type: text/plain; charset=US-ASCII


Thanks for the tip. I have no problems with other approaches than DDE but since I know the rudiments of it and seldom need to do this type of operation, there is not much incentive for me to take the time to learn a replacement.


Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

Arthur Tabachneck <art297@NETSCAPE. NET> To SAS-L@LISTSERV.UGA.EDU, Nat Wooding 08/23/2008 06:43 <Nathaniel.Wooding@DOM.COM> PM cc

Subject Re: SAS issuing print command to Word


Not that I favor a dde solution, but the definition of range and alternatives for only printing the first page using dde can be found at:

Art ------- On Sat, 23 Aug 2008 17:55:03 -0400, Nat Wooding <Nathaniel.Wooding@DOM.COM> wrote:

>Art et al. > >I sent Joakim a note off line in which I showed how to print all of the >documents in a folder using dde and old style macros. I do not have access >to a list of word basic macros but it would seem likely that there would be >a function or object that would specify which pages to print just as one >sees when one selects Print under the File dropdown and you can print the >whole doc, the current page, or pages a to b. I would assume that VBA would >have a similar object. I have found hints of a pages object but was not >able to make it work as I wished. > >My code is below and is admitedly kludgy since I don't use macro loops a >lot and chose the quick way of writing the macro calls to a file and then >pasting them into my program. > >/* THIS WAS used to grab a list of files to process > > >filename dirfiles pipe 'dir "C:\whatever'; > >data files; > infile dirfiles truncover; > > input str $ 1-60; >file print;put _infile_; > if index ( str , 'doc' ) ; > file = scan ( scan ( str , -1 , ' ' ) , 1 , '.' ) ; > filename create 'c:\park\name for file of macro'; > file create; > put '%READIT( ' file ')#' ; >run; > >*/ > filename wordsys dde 'winword|system' lrecl=5000; > >%macro readit(worddoc); > %* Minimize the Word application. *; > data _null_; > file wordsys; > put '[AppMinimize]'; > run ; > > > %* Set the default directory and open the document containing a *; > %* table. > *; > data _null_; > file wordsys; > string=compress('''[FileOpen.Name='||"""&worddoc"""||' >.ConfirmConversions=0]'''); > call symput('string',string); > > put '[ChDefaultDir "C:\Coastal Tox\Old Format",0]'; > >RUN; > > >data _null_; > file wordsys; > put &string; > run; > > > > data _null_; > file wordsys; > * the next line tells sas to print the file. I'm not sure what .range >refers to; > put '[FilePrint.Range=0]'; > > * I could not get the following to work > put '[FilePrint.Range=0,Pages:="1"]'; > put '[Fileclose]'; > > run; > quit; > > %mend readit; > >%READIT( aaaa1.doc);* these are the names of the files to print and were >copied from an external file after the > first chunk of code generated them.; >%READIT( bbbb2.doc); > >* the following bits tell me when the printing is done. first, write a >message to the output >window and then play a series of notes; > >Data _null_; >file print; > >put 'all done '; > >put 'all done '; > >put 'all done '; > >put 'all done '; >run; > >DATA _NULL_; > Do i = 200 to 2500 by 250 ; > call sound(i,100); > end; > > Do i = 2500 to 200 by 250 ; > call sound(i,100); > end; > >run; > > >Nat Wooding >Environmental Specialist III >Dominion, Environmental Biology >4111 Castlewood Rd >Richmond, VA 23234 >Phone:804-271-5313, Fax: 804-271-2977 > > > > Arthur Tabachneck > <art297@NETSCAPE. > NET> To > Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU > Discussion" cc > <SAS-L@LISTSERV.U > GA.EDU> Subject > Re: SAS issuing print command to > Word > 08/23/2008 04:23 > PM > > > Please respond to > Arthur Tabachneck > <art297@NETSCAPE. > NET> > > > > > > >Joakim, > >As Joe and Howard pointed out, you can probably do what you want with >either dde or SAS/AF. > >I, personally, find developing vbs code (outside of SAS), a lot more >parsimonious, easier to explain and easier to change. > >However, I'm still not sure if my latest version will do what you want, as >it still prints all pages on my printer. Since that could just be my >outdated home printer driver, I'd suggest at least trying it on some >relatively small files. > >The "1-1" part of the "put @1 'objWord.PrintOut ,,,,,,,,"1-1",,,,"'@;" >statement, below, according to Microsoft should print only the range of >pages 1 thru 1. > >Art >----- >*identify the desired files; >FileName GetDir Pipe "dir c:\art\*.doc /d /B /s" ; > >* build vbs program; >data _null_; > file "s:\art\getdocs.vbs" LRECL =300; > infile GetDir lrecl=300 truncover; > input @1 fullpath $255. @; > put @1 'Set objWord = CreateObject("Word.Application")'; > put @1 'objWord.Visible = True'; > put @1 'Set objDoc = objWord.Documents.Add()'; > put @1 'objWord.PrintOut ,,,,,,,,"1-1",,,,"'@; > put fullpath @; > put '"'; > put @1 'objWord.Quit'; >run; > >*run vbs code; >option noxsync; >data _null_; > x "c:\art\getdocs.vbs"; >run; > >Art >-------------- >>Joakim, >> >>The following is NOT the full solution, but it may be enough to prompt >>someone from the list (who is better at vbs than I am) to (1) add the >>missing fromto command (which does exist in word script) and (2) show how >>the concept can be simplified. >> >>In any case, you can build and run vbs script from SAS. Take, for >>example, the following: >> >>*identify the desired files; >>FileName GetDir Pipe "dir c:\art\*.doc /d /B /s" ; >> >>* build vbs program; >>data _null_; >> file "s:\art\getdocs.vbs" LRECL =300; >> infile GetDir lrecl=300 truncover; >> input @1 fullpath $255. @; >> put @1 'Set objWord = CreateObject("Word.Application")'; >> put @1 'Set objDoc = objWord.Documents.Open("'@; >> put fullpath @; >> put '")'; >> put @1 'objDoc.PrintOut()'; >> put @1 'objWord.Quit'; >>run; >> >>*run vbs code; >>option noxsync; >>data _null_; >> x "c:\art\getdocs.vbs"; >>run; >> >>The first part uses a pipe to identify the fullpaths of the files you want >>to print. >> >>The second part builds a vbs program that prints the files. >> >>The third part actually runs the vbs code. >> >>I think the code can be simplified quite a bit and, of course, someone has >>to suggest what it needed to limit the code to only print the first page >>from each document. >> >>HTH, >>Art >>--------- >>On Fri, 22 Aug 2008 21:00:18 +0200, Joakim Englund >><joakim.englund@GMAIL.COM> wrote: >> >>>Dear professionals, >>> >>>Is there a way using SAS code to command Word to print the first page of >>all >>>word files in a directory? >>> >>>Kind Regards, >>>Joakim > > >CONFIDENTIALITY NOTICE: This electronic message contains >information which may be legally confidential and/or privileged and >does not in any case represent a firm ENERGY COMMODITY bid or offer >relating thereto which binds the sender without an additional >express written confirmation to that effect. The information is >intended solely for the individual or entity named above and access >by anyone else is unauthorized. If you are not the intended >recipient, any disclosure, copying, distribution, or use of the >contents of this information is prohibited and may be unlawful. If >you have received this electronic transmission in error, please >reply immediately to the sender that you have received the message >in error, and delete it. Thank you.

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