Some months ago, I wrote some code to send values from an Excel worksheet to a Word document and print that document. The values were from a row, with multiple rows rendering multiple print files. VBAX responders provided several items that assisted in this function. When I used it recently, it began "skipping" rows, i.e. there were about 33 documents produced instead of the intended 42.
When I originally encountered this problem, Charlize suggested that I add a "wait" after my "print command". This worked... until now. Since my symptoms were identical to the original symptoms, I have added additional "wait" commands and the problem is solved... again.
Chances are my shotgun technique is not very good. I am enclosing two snippets of the code, showing the "before" and "after". Where do I really need these waits? I thought I understood the original answer!
The original thread : http://www.vbaexpress.com/forum/show...t=12181&page=2
Set wrdApp = New Word.Application
wrdApp.Visible = False
Set wrdDoc = wrdApp.Documents.Open(FileName:="c:\Recap\New Monthly Recap.dot")
wrdApp.Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
Application.Wait (Now + TimeValue("00:00:04"))
Set wrdDoc = Nothing
wrdApp.Quit savechanges:=False
Set wrdApp = Nothing
This is the original code with the one inserted wait after the print. The second example shows the added "wait" commands.
Set wrdApp = New Word.Application
Application.Wait (Now + TimeValue("00:00:01"))
wrdApp.Visible = False
Set wrdDoc = wrdApp.Documents.Open(FileName:="c:\Recap\New Monthly Recap.dot")
Application.Wait (Now + TimeValue("00:00:02"))
wrdApp.Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
Application.Wait (Now + TimeValue("00:00:04"))
Set wrdDoc = Nothing
Application.Wait (Now + TimeValue("00:00:01"))
wrdApp.Quit savechanges:=False
Set wrdApp = Nothing
Thanks for your input.