K
Kenny G
Hello,
Using Access 2002/Word 2002
I have an Access DB and a Word.dot letter. The user of the Access DB fills
in the appropriate fields and at the end of the data entry the user has the
option of printing their data entry. Once the user clicks Print the Word.dot
opens but the bookmarks I have in the .dot document does not populate with
the record results.
I get an error message: Object required.
Here is the code. Perhaps you might be able to tell me what is missing.
Sub PrintHazSurvRptWithWord(DataEntryForm)
Dim objWord As Word.Application
'Launch Word and load the HazardSurveillanceReport template
Set objWord = New Word.Application
objWord.Documents.Open "\\Sharedir\safety
database\Documents\HazardSurveillanceSurvey.dot"
objWord.ActiveDocument.FollowHyperlink "\\Sharedir\safety
database\Documents\HazardSurveillanceSurvey.dot"
objWord.Visible = True
'Add information using predefined bookmarks
With objWord.ActiveDocument.Bookmarks
.Item("Director").Range.Text = ReportPrintForm.Director
.Item("OverallTotal").Range.Text = ReportPrintForm.OverallTotal
.Item("STotal").Range.Text = ReportPrintForm.STotal
.Item("SCTotal").Range.Text = ReportPrintForm.SCTotal
.Item("HZTotal").Range.Text = ReportPrintForm.HZTotal
.Item("EMTotal").Range.Text = ReportPrintForm.EMTotal
.Item("FTotal").Range.Text = ReportPrintForm.FTotal
.Item("METotal").Range.Text = ReportPrintForm.METotal
.Item("UTotal").Range.Text = ReportPrintForm.UTotal
.Item("ICTotal").Range.Text = ReportPrintForm.ICTotal
.Item("CorrectiveActionDate").Range.Text =
ReportPrintForm.CorrectiveActionDate
.Item("S1").Range.Text = DataEntryForm.S1
I appreciate your help.
Kenny G
Using Access 2002/Word 2002
I have an Access DB and a Word.dot letter. The user of the Access DB fills
in the appropriate fields and at the end of the data entry the user has the
option of printing their data entry. Once the user clicks Print the Word.dot
opens but the bookmarks I have in the .dot document does not populate with
the record results.
I get an error message: Object required.
Here is the code. Perhaps you might be able to tell me what is missing.
Sub PrintHazSurvRptWithWord(DataEntryForm)
Dim objWord As Word.Application
'Launch Word and load the HazardSurveillanceReport template
Set objWord = New Word.Application
objWord.Documents.Open "\\Sharedir\safety
database\Documents\HazardSurveillanceSurvey.dot"
objWord.ActiveDocument.FollowHyperlink "\\Sharedir\safety
database\Documents\HazardSurveillanceSurvey.dot"
objWord.Visible = True
'Add information using predefined bookmarks
With objWord.ActiveDocument.Bookmarks
.Item("Director").Range.Text = ReportPrintForm.Director
.Item("OverallTotal").Range.Text = ReportPrintForm.OverallTotal
.Item("STotal").Range.Text = ReportPrintForm.STotal
.Item("SCTotal").Range.Text = ReportPrintForm.SCTotal
.Item("HZTotal").Range.Text = ReportPrintForm.HZTotal
.Item("EMTotal").Range.Text = ReportPrintForm.EMTotal
.Item("FTotal").Range.Text = ReportPrintForm.FTotal
.Item("METotal").Range.Text = ReportPrintForm.METotal
.Item("UTotal").Range.Text = ReportPrintForm.UTotal
.Item("ICTotal").Range.Text = ReportPrintForm.ICTotal
.Item("CorrectiveActionDate").Range.Text =
ReportPrintForm.CorrectiveActionDate
.Item("S1").Range.Text = DataEntryForm.S1
I appreciate your help.
Kenny G