J
Julia
I have created a from with a button. In the on click event, there has
the following code to generate the current record to a word template.
The form has also linked to a query as the data source. May I know how
to edit the code in order to export all the records from the query to
the word template?
thank, julia
********************************************************************
Dim objWord As Object
' Open Microsoft Word using automation
Set objWord = New Word.Application
objWord.Documents.Add "c:\FormLetter.dot"
objWord.Visible = True
' The following code is generated from your Access form while it is
' manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word VBA.
If objWord.ActiveDocument.Bookmarks.Exists("FirstName") = True Then
objWord.ActiveDocument.Bookmarks("FirstName").Range.Text =
me!FirstName
End If
If objWord.ActiveDocument.Bookmarks.Exists("LastName") = True Then
objWord.ActiveDocument.Bookmarks("LastName").Range.Text =
me!LastName
End If
the following code to generate the current record to a word template.
The form has also linked to a query as the data source. May I know how
to edit the code in order to export all the records from the query to
the word template?
thank, julia
********************************************************************
Dim objWord As Object
' Open Microsoft Word using automation
Set objWord = New Word.Application
objWord.Documents.Add "c:\FormLetter.dot"
objWord.Visible = True
' The following code is generated from your Access form while it is
' manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word VBA.
If objWord.ActiveDocument.Bookmarks.Exists("FirstName") = True Then
objWord.ActiveDocument.Bookmarks("FirstName").Range.Text =
me!FirstName
End If
If objWord.ActiveDocument.Bookmarks.Exists("LastName") = True Then
objWord.ActiveDocument.Bookmarks("LastName").Range.Text =
me!LastName
End If