C
cefrancke
I have a procedure that uses Automation to open a Word .dot (template)
file and fills in bookmarks for each record of a recordset.
After filling in the info for a record I want to print the document,
close it, and move on to the next record.
But the documents are not printing.
Do I have to give the printer time enough to print before closing the
document and moving on? How do I know when I can move to the next
document?
Sample code:
Do Until rs.EOF
Set objWordDoc = objWord.Documents.Add("MyDoc.dot")
With objWordDoc.Bookmarks
If .Exists("MyBM") Then
.Item("MyBM").Range.Text = rs!MyData
End If
End With
'Print
objWordDoc.PrintOut , , , , , , , 2 '2 Copies
objWordDoc.Close wdDoNotSaveChanges
rsCS.MoveNext
Loop
TIA
file and fills in bookmarks for each record of a recordset.
After filling in the info for a record I want to print the document,
close it, and move on to the next record.
But the documents are not printing.
Do I have to give the printer time enough to print before closing the
document and moving on? How do I know when I can move to the next
document?
Sample code:
Do Until rs.EOF
Set objWordDoc = objWord.Documents.Add("MyDoc.dot")
With objWordDoc.Bookmarks
If .Exists("MyBM") Then
.Item("MyBM").Range.Text = rs!MyData
End If
End With
objWordDoc.PrintOut , , , , , , , 2 '2 Copies
objWordDoc.Close wdDoNotSaveChanges
rsCS.MoveNext
Loop
TIA