Getting a compile error 'user defined type not defined' on the 'Dim objWord as Word Document'
I researched the internet and found that I might have a problem with the Object Library from the References tab when the Module sheet is open. My Access installation has 'Microsoft DAO 3.6 Object Library' checked. I tried the test again and, of course, it failed again since I had not changed anything.
The merge is using data from a Make Table query and a merge document located on my C: drive. The code is below... Help is greatly appreciated!
Thanks, jketcher
Private Sub Create_Report_Click()
On Error GoTo Err_Create_Report_Click
Dim objWord As Word.Application
Set objWord = GetObject("C:\Documents and Settings\jketcher\My Documents\Janis Folder November 6\ECG\MS Access Projects\ECGOpReview", _
"Word.Document")
'Make Word visible.
objWord.Application.Visible = True
'Set the mail merge data source as
objWord.MailMerge.OpenDataSource _
Name:="tbl_merge_findings"
'Execute the mail merge
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
' Save and close the new document
objWord.Application.Options.SaveInterval = False
objWord.Application.ActiveDocument.SaveAs "OpReview_MailMerge"
objWord.Application.ActiveDocument.Close
objWord.Application.Quit wdDoNotSaveChanges
MsgBox "Mail Merge Complete!", vbOKOnly, "File Done"
DoCmd.Quit
Exit_Create_Report_Click:
Exit Sub
I researched the internet and found that I might have a problem with the Object Library from the References tab when the Module sheet is open. My Access installation has 'Microsoft DAO 3.6 Object Library' checked. I tried the test again and, of course, it failed again since I had not changed anything.
The merge is using data from a Make Table query and a merge document located on my C: drive. The code is below... Help is greatly appreciated!
Thanks, jketcher
Private Sub Create_Report_Click()
On Error GoTo Err_Create_Report_Click
Dim objWord As Word.Application
Set objWord = GetObject("C:\Documents and Settings\jketcher\My Documents\Janis Folder November 6\ECG\MS Access Projects\ECGOpReview", _
"Word.Document")
'Make Word visible.
objWord.Application.Visible = True
'Set the mail merge data source as
objWord.MailMerge.OpenDataSource _
Name:="tbl_merge_findings"
'Execute the mail merge
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
' Save and close the new document
objWord.Application.Options.SaveInterval = False
objWord.Application.ActiveDocument.SaveAs "OpReview_MailMerge"
objWord.Application.ActiveDocument.Close
objWord.Application.Quit wdDoNotSaveChanges
MsgBox "Mail Merge Complete!", vbOKOnly, "File Done"
DoCmd.Quit
Exit_Create_Report_Click:
Exit Sub