G
GaryM@optusnet
The Access database mailmerges a Word template which has its data source as a
table in the access database and creates a new document. This works without a
problem in Access XP (Office 10) but when it runs on a PC with Access 2003
(office 11) it creates a message that the template is not a main mailmerge
document. I have observed that in VBA tool/reference menu it has selected
the MS Word 10 Object library with Access XP and the MS Word 11 Object
library with Access 2003.
The VBA code is
Private Sub OpenMergedDoc(TemplateDocName As String, strSQL As String,
strReportType As String)
On Error GoTo WordError
Dim objWord As New Word.Application
Dim objDoc As Word.Document
objWord.Application.Visible = True
Set objDoc = objWord.Documents.Open(TemplateDocName.dot)
objDoc.MailMerge.Execute
objWord.Application.Documents(1).SaveAs (NewDocument.doc)
objWord.Application.Documents(2).Close wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing
Exit Sub
WordError:
MsgBox "Err #" & Err.Number & " occurred." & Err.Description,
vbOKOnly, "Word Error"
objWord.Quit
End Sub
The error occurs with the statement "objDoc.MailMerge.Execute"
Is the Word 11 Object library not backward compatible with the above code or
is there an bug in Microsofts code.
If there is no problem in Microsofts code then i will need to write two
mobule based on the version of office running on the PC. This would be absurd.
Any help please
table in the access database and creates a new document. This works without a
problem in Access XP (Office 10) but when it runs on a PC with Access 2003
(office 11) it creates a message that the template is not a main mailmerge
document. I have observed that in VBA tool/reference menu it has selected
the MS Word 10 Object library with Access XP and the MS Word 11 Object
library with Access 2003.
The VBA code is
Private Sub OpenMergedDoc(TemplateDocName As String, strSQL As String,
strReportType As String)
On Error GoTo WordError
Dim objWord As New Word.Application
Dim objDoc As Word.Document
objWord.Application.Visible = True
Set objDoc = objWord.Documents.Open(TemplateDocName.dot)
objDoc.MailMerge.Execute
objWord.Application.Documents(1).SaveAs (NewDocument.doc)
objWord.Application.Documents(2).Close wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing
Exit Sub
WordError:
MsgBox "Err #" & Err.Number & " occurred." & Err.Description,
vbOKOnly, "Word Error"
objWord.Quit
End Sub
The error occurs with the statement "objDoc.MailMerge.Execute"
Is the Word 11 Object library not backward compatible with the above code or
is there an bug in Microsofts code.
If there is no problem in Microsofts code then i will need to write two
mobule based on the version of office running on the PC. This would be absurd.
Any help please