Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print a word doc for x records, then close word in background

Status
Not open for further replies.

DaJoin

Technical User
Sep 15, 2002
9
BE
I have a form with a number of member records.
I want to print a document for each of these members with their data in it (the merge works fine), and then close the document, but this seems not to work well .

This is the code I use, any comments are welcome .

Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
' Make the application visible.
' Open the document.
' .Documents.Open ("c:\my documents\testmerge.doc")
' Move to each bookmark and insert text from the form.
DoCmd.GoToRecord , , acFirst
For i = 0 To Me.Recordset.RecordCount - 1
If Me.selected = -1 Then
.Documents.Add ("c:\my documents\testmerge.doc")

.ActiveDocument.Bookmarks("naam").Select
.Selection.Text = (CStr(Forms!leden!naam))
...
.ActiveDocument.PrintOut Background:=False
End If
Me.Recordset.MoveNext
Next i
.Visible = True
End With
objWord.Quit acExit
Set objWord = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top