Select Table dialog box comes up twice when open data source

P

Paula Jern

Hi,
I have a macro that uses mail merge to print labels from an Excel file. The
Excel file always contains only one tab. I have the following code in my
macro:
ActiveDocument.MailMerge.OpenDataSource Name:=path, _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, connection:="Entire Spreadsheet",
SQLStatement _
:=""
When the user selects the data source to open, the 'Select Table' dialog box
comes up twice (with the same table name in it). I found that if I put
something like SELECT * FROM `export$` in the value for the SQLStatement
property, it suppresses one of the dialog boxes. The problem is, the name of
the table to select from may not always be the same. Does anyone know how I
can suppress one of the dialog boxes without hardcoding the table name?
Thank you!
Paula
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top