A
AJ
I am trying to output some fields from a table to a word merge document. I
have created the word document. When I run my code I get an error at the
".OpendataSource (strTableName). The error says it cannot find the "file". I
know the table is there. Any suggestions? Any help would be appreciated>my
coding is as follows:
Sub MergeWord(strReportName, strTableName)
Dim dbs As DAO.Database
Dim wApp As Object
Dim wDoc As Object
Dim wActiveDoc As Word.Document
Set dbs = CurrentDb
Set wApp = CreateObject("Word.Application")
Set wDoc = wApp.Documents.Open(strReportName)
With wDoc.MailMerge
.OpenDataSource (strTableName)
.Destination = wdSendToNewDocument
.Execute
End With
Set wActiveDoc = wApp.ActiveDocument
wActiveDoc.Visible = True
Set dbs = Nothing
Set rst = Nothing
Set wApp = Nothing
Set wDoc = Nothing
Set wActiveDoc = Nothing
End Sub
Thank You
have created the word document. When I run my code I get an error at the
".OpendataSource (strTableName). The error says it cannot find the "file". I
know the table is there. Any suggestions? Any help would be appreciated>my
coding is as follows:
Sub MergeWord(strReportName, strTableName)
Dim dbs As DAO.Database
Dim wApp As Object
Dim wDoc As Object
Dim wActiveDoc As Word.Document
Set dbs = CurrentDb
Set wApp = CreateObject("Word.Application")
Set wDoc = wApp.Documents.Open(strReportName)
With wDoc.MailMerge
.OpenDataSource (strTableName)
.Destination = wdSendToNewDocument
.Execute
End With
Set wActiveDoc = wApp.ActiveDocument
wActiveDoc.Visible = True
Set dbs = Nothing
Set rst = Nothing
Set wApp = Nothing
Set wDoc = Nothing
Set wActiveDoc = Nothing
End Sub
Thank You