WTsuk
asked on
Access VB - avoid prompt to Select Table Mail Merge
Access 2007 VB print Mail Merge Word 2007. It prompt to Select Table. I want to know VB auto print without Prompt Select Table.
Private Sub PrintMMword()
Dim templateName As String, tempRoot As String
tempRoot = "C:\wordtech\mailmerge\"
templateName = tempRoot & "msseq1.docx"
Dim objDoc As Word.Document
Dim objWord As New Word.Application
Dim outputFileName As String
outputFileName = CurrentProject.Path & "\Qmail.xls"
With objWord
.DisplayAlerts = False
.Application.Visible = False
Set objDoc = objWord.Documents.Open(tem plateName)
With objDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:=outputFileName, LinkToSource:=True
.Destination = wdSendToPrinter
.Execute
End With
.Quit SaveChanges:=False
End With
Set objWord = Nothing
Set objDoc = Nothing
End Sub
Private Sub PrintMMword()
Dim templateName As String, tempRoot As String
tempRoot = "C:\wordtech\mailmerge\"
templateName = tempRoot & "msseq1.docx"
Dim objDoc As Word.Document
Dim objWord As New Word.Application
Dim outputFileName As String
outputFileName = CurrentProject.Path & "\Qmail.xls"
With objWord
.DisplayAlerts = False
.Application.Visible = False
Set objDoc = objWord.Documents.Open(tem
With objDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:=outputFileName, LinkToSource:=True
.Destination = wdSendToPrinter
.Execute
End With
.Quit SaveChanges:=False
End With
Set objWord = Nothing
Set objDoc = Nothing
End Sub
ASKER
I still getting Prompt Table Selection. i have to click OK on the Prompt Table Selection.
Have you changed YourTable with your Source Table or Query
ASKER
There are two table names on prompt box. MMout and MMout$
I changed Table name and still got Prompt box.
Connection:="TABLE MMout"
I changed Table name and still got Prompt box.
Connection:="TABLE MMout"
is MMout a query or a Table
if a query try "VIEW MMout"
if a query try "VIEW MMout"
ASKER
file is excel file. Qmail.xls. It is exported from access table (the table name is MMout). MMout is the Sheet name on Qmail.xls. When I open Qmail.xls, I only see MMout. I do not see MMout$. But on Merge Document Prompt box shows two table name. MMout and MMout$.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. It printed without Prompt box.
ASKER
Thank you very much. It saved a lot of time.
pls try
Open in new window
Regards