mitchell50
10-29-2007, 04:53 PM
I have written some VBA code in Word 2003. It takes advantage of the MailMergeBeforeRecordMerge event. It seems to work fine on Word 2003 but when someone tries use it in a Word 2000 environment, the event doesn't fire.
I don't have any events in the Normal.dot document. In the merge document I set a public object to an instance of the application as follows:
Public WithEvents Wrd As WORD.Application
Private Sub Document_Open()
Set Wrd = ThisDocument.Application
End Sub
The Document_Open() sub fires just fine in W2000. It even seems to set the instance. But the following event doesn't fire:
Private Sub Wrd_MailMergeBeforeRecordMerge(ByVal Doc As Document, Cancel As Boolean)
For Each Item In Doc.MailMerge.DataSource.DataFields
MsgBox "Field Name: " & Item.Name & " Value: " & Item.Value
Next
End Sub
I do remember one time I had to set up a public object in Normal.dot that was set to a class (with events) whenever Normal was initiated. Is this what I should do? I hate the idea of having to alter the Normal.dot on every computer that is going to use this document.
I don't have any events in the Normal.dot document. In the merge document I set a public object to an instance of the application as follows:
Public WithEvents Wrd As WORD.Application
Private Sub Document_Open()
Set Wrd = ThisDocument.Application
End Sub
The Document_Open() sub fires just fine in W2000. It even seems to set the instance. But the following event doesn't fire:
Private Sub Wrd_MailMergeBeforeRecordMerge(ByVal Doc As Document, Cancel As Boolean)
For Each Item In Doc.MailMerge.DataSource.DataFields
MsgBox "Field Name: " & Item.Name & " Value: " & Item.Value
Next
End Sub
I do remember one time I had to set up a public object in Normal.dot that was set to a class (with events) whenever Normal was initiated. Is this what I should do? I hate the idea of having to alter the Normal.dot on every computer that is going to use this document.