E
Eric
I'm trying to create a mailmerge document from within access 2007, the
problem is that each time the function is fired the function ask for the
table to be selected whilst the name of the table is hardcoded in the
function, this is really most strange.
Below is the function:
Dim WordApp As New Word.Application
Dim inDoc As String
Dim outDoc As String
Dim strSubject, strRecip, strMsg As String
Dim strAttachment As String
Dim db As Database
Dim rs As Recordset
Dim accrcv As Recordset
inDoc = "Q:\DOCS\Outstanding Bill - First ReminderPK.docx"
outDoc = "C:\temp\outstandingbillpk.docx"
WordApp.Visible = True
WordApp.Documents.Open (inDoc)
With WordApp.ActiveDocument.Mailmerge
..MainDocumentType = wdFormLetters
..OpenDataSource Name:=CurrentDb.Name, Connection:="Table 1streminder"
..Destination = wdSendToNewDocument
..SuppressBlankLines = True
..Execute
End With
WordApp.Documents(1).SaveAs outDoc
WordApp.Documents(2).Close False
WordApp.Quit
Set WordApp = Nothing
Does anyone knows why I'm getting the window where one needs to select the
name of the table??? Many thanks....
problem is that each time the function is fired the function ask for the
table to be selected whilst the name of the table is hardcoded in the
function, this is really most strange.
Below is the function:
Dim WordApp As New Word.Application
Dim inDoc As String
Dim outDoc As String
Dim strSubject, strRecip, strMsg As String
Dim strAttachment As String
Dim db As Database
Dim rs As Recordset
Dim accrcv As Recordset
inDoc = "Q:\DOCS\Outstanding Bill - First ReminderPK.docx"
outDoc = "C:\temp\outstandingbillpk.docx"
WordApp.Visible = True
WordApp.Documents.Open (inDoc)
With WordApp.ActiveDocument.Mailmerge
..MainDocumentType = wdFormLetters
..OpenDataSource Name:=CurrentDb.Name, Connection:="Table 1streminder"
..Destination = wdSendToNewDocument
..SuppressBlankLines = True
..Execute
End With
WordApp.Documents(1).SaveAs outDoc
WordApp.Documents(2).Close False
WordApp.Quit
Set WordApp = Nothing
Does anyone knows why I'm getting the window where one needs to select the
name of the table??? Many thanks....