|
I am trying to automate the merging of data from an Excel spreadsheet into a Word document. The code below works, however, I have to press "OK" when it's trying to open the data source. It wants me to select the table to use (which is the only 'table' in the spreadsheet -- so the selection defaults to it anyway).. I'd like to NOT have to press enter.. and for the mail merge to just accept the default table selected. .. Any ideas?
Set WORDApp = CreateObject("Word.Application")
WORDApp.Visible = 0
WORDApp.DisplayAlerts = False
WORDApp.Documents.Open "c:\billimage\GENERICM.doc"
wformat = 1
wconfirmconv = 0
wreadonly = 0
wlinktosource = 1
waddtofilelist = 0
wpassworddoc = ""
wpasswordtemp = ""
wrevert = 0
wprotectdoc = ""
wprotecttemp = ""
wconn = ""
wsqlstatement = "" WORDApp.ActiveDocument.MailMerge.OpenDataSource xlsfile, wformat, wconfirmconv, wreadonly, wlinktosource, waddtofilelist, wpassworddoc, wpasswordtemp, wrevert, wprotectdoc, wprotecttemp, wconn, wsqlstatement
With WORDApp.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With
|
|
|
|
|
|
|
// |