Want to suppress "Select Table" dialog box for Mail Merge automation with Excel data source

I am automating a Mail Merge process in my application.   The data source is an Excel workbook created eariler by the application.  I specify the Excel workbook as the data source and the named range as the "Connection".  It works fine except that a dialog box is displayed by Word with the caption "Select Table" with the specified named range highlighted.  I have to manually click "OK" for the named range to be used as the table and then the Mail Merge completes successfully.

Is there is a way to suppress the "Select Table" dialog box which is displayed during the processing of the myDoc.MailMerge.OpenDataSource statement?

Ernie D

myDoc = appWord.Documents.Open(dotFile)
myDoc.MailMerge.OpenDataSource(Name:=gExcelFile, _
            ConfirmConversions:=False, _
            ReadOnly:=False, _
            LinkToSource:=True, _
            AddToRecentFiles:=False, _
            PasswordDocument:="", PasswordTemplate:="", _
            WritePasswordDocument:="", _
            WritePasswordTemplate:="", _
            Revert:=False, _
            Format:=Word.WdOpenFormat.wdOpenFormatAuto, _
            Connection:="AddressList", _
            SQLStatement:="SELECT * FROM 'Address Data$'", _

Open in new window

Who is Participating?
grace4meConnect With a Mentor Author Commented:
Hi All,  

I have resolved this problem.   The resolution was to use the "TABLE" qualifier with the "Connection:=" parameter on line 13 of the code snippet. In other words the line:
        Connection:="AddressList", _
was changed to:
        Connection:="TABLE AddressList", _
This prevented the "Select Table" dialog window from being displayed.
All Courses

From novice to tech pro — start learning today.