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
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