I had the following code working to print custom copies of word documents. However, it has recently stopped working. The problem is, it used to work, so I must have changed something. It seems simple, and everything should work, but I have come to the end of my rope, and do not know the way further.
According to the 4th line, it will print 4, right? For me it prints 1 copy. Can anyone take a look at this and tell me if this code does the same for you? And provide pointers for troubleshooting?
Thanks in advance.
Code: Select all
printpath := "C:\Temp\blank.docx" ; blank word document to save toner
oWord := ComObjCreate("Word.Application") ; create MS Word object
oFile := oWord.Documents.Open(printpath) ; create new document
oWord.DisplayAlerts := 0 ; turns off alerts, so that "your margins are too small" warnings don't interrupt (because I can deal with the consequences myself if it doesn't print right, which it won't)
oFile.PrintOut( Copies:=4, Background:=false )
oWord.DisplayAlerts := -1 ; turns them back on
oFile.Close ; close the file
oFile := "" ; release the reference
oWord.Quit ; close the application
oWord := "" ; release the reference