Print Multiple Copies - Access Word Automation

  • Thread starter Thread starter cefrancke
  • Start date Start date
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
 
Try adding a do events here:

objWordDoc.PrintOut , , , , , , , 2 '2 Copies
DoEvents
objWordDoc.Close wdDoNotSaveChanges

Somethimes 1 isn't enough during automation. A recent Powerpoint project
required 3 of them, so:

Dim i As Integer
For i = 1 to 3
DoEvents
Next i
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top