J
Jonathan
Hello all,
I'm trying to automate an MS-Word 2002 mail merge operation using an Access
2002 database as the data source. I created a Word document with the MM
fields already set up. The MM fields are mapped to the database.
I have a VB 6.0 program that populates the records in the database and then
opens up the word document. Word launches and the specified document opens
but the merge does not execute. The MM fields are there but they aren't
populated. Here's the code. Any help would be appreciated.
-Jonathan
Private Sub OpenDoc(Index As Integer)
Err.Number = 0
On Error GoTo NotLoaded
Set appMSWord = GetObject(, "Word.Application")
NotLoaded:
Select Case Err.Number
Case 429
Set appMSWord = CreateObject("Word.Application")
Case 0
MsgBox "Close all open MS-Word documents.", vbOKOnly, gsTitle
Exit Sub
Case Else
ErrorHandler Err.Number, Err.Description, "OpenDoc()"
Exit Sub
End Select
On Error GoTo opendoc_EH
appMSWord.Visible = True
Select Case Index
Case 0
appMSWord.Documents.Open "doc1.doc"
Case 1
appMSWord.Documents.Open "doc2.doc"
Case 2
appMSWord.Documents.Open "doc3.doc"
Case 3
appMSWord.Documents.Open "doc4.doc"
Case 4
appMSWord.Documents.Open "doc5.doc"
Case 5
appMSWord.Documents.Open "doc6.doc"
Case Else
MsgBox "Invalid document specified.", vbCritical, gsTitle
End Select
OpenDoc_Exit:
Exit Sub
opendoc_EH:
ErrorHandler Err.Number, Err.Description, "OpenDoc()"
Resume OpenDoc_Exit
End Sub
I'm trying to automate an MS-Word 2002 mail merge operation using an Access
2002 database as the data source. I created a Word document with the MM
fields already set up. The MM fields are mapped to the database.
I have a VB 6.0 program that populates the records in the database and then
opens up the word document. Word launches and the specified document opens
but the merge does not execute. The MM fields are there but they aren't
populated. Here's the code. Any help would be appreciated.
-Jonathan
Private Sub OpenDoc(Index As Integer)
Err.Number = 0
On Error GoTo NotLoaded
Set appMSWord = GetObject(, "Word.Application")
NotLoaded:
Select Case Err.Number
Case 429
Set appMSWord = CreateObject("Word.Application")
Case 0
MsgBox "Close all open MS-Word documents.", vbOKOnly, gsTitle
Exit Sub
Case Else
ErrorHandler Err.Number, Err.Description, "OpenDoc()"
Exit Sub
End Select
On Error GoTo opendoc_EH
appMSWord.Visible = True
Select Case Index
Case 0
appMSWord.Documents.Open "doc1.doc"
Case 1
appMSWord.Documents.Open "doc2.doc"
Case 2
appMSWord.Documents.Open "doc3.doc"
Case 3
appMSWord.Documents.Open "doc4.doc"
Case 4
appMSWord.Documents.Open "doc5.doc"
Case 5
appMSWord.Documents.Open "doc6.doc"
Case Else
MsgBox "Invalid document specified.", vbCritical, gsTitle
End Select
OpenDoc_Exit:
Exit Sub
opendoc_EH:
ErrorHandler Err.Number, Err.Description, "OpenDoc()"
Resume OpenDoc_Exit
End Sub