S
SRobertson2
I have a Word 2002 document that is linked to an ODBC data source (an Access
table). I want to open this doucment (with merged data) from a button in
Access.
The following code fails because the document never opens in a
"wdMainAndDataSource" state. What am I doing wrong?
Dim wApp As Word.Application
Dim wDoc As Word.Document
Dim wMM As Word.MailMerge
Set wApp = CreateObject("Word.Application")
wApp.Visible = True
Set wDoc = wApp.Documents.Open("C:\Donating.doc")
Set wMM = ActiveDocument.MailMerge
If wMM.State = wdMainAndDataSource Then
wMM.Destination = wdSendToNewDocument
wMM.Execute
End If
table). I want to open this doucment (with merged data) from a button in
Access.
The following code fails because the document never opens in a
"wdMainAndDataSource" state. What am I doing wrong?
Dim wApp As Word.Application
Dim wDoc As Word.Document
Dim wMM As Word.MailMerge
Set wApp = CreateObject("Word.Application")
wApp.Visible = True
Set wDoc = wApp.Documents.Open("C:\Donating.doc")
Set wMM = ActiveDocument.MailMerge
If wMM.State = wdMainAndDataSource Then
wMM.Destination = wdSendToNewDocument
wMM.Execute
End If