View Single Post
  #1   Report Post  
Paula Jern
 
Posts: n/a
Default Select Table dialog box comes up twice when open data source

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