View Single Post
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
jm_dunning jm_dunning is offline
external usenet poster
 
Posts: 1
Default Word/Excel VBA mail merge fails with filtered results

I have a VBA macro that copies uses an Excel file to do a mail merge
in Word. Everything works properly, except if the Excel file has
filtering, in which case I get

Run-time error '5640':
Word could not re-establish a DDE connection to Microsoft Excel to
complete the current task

The code I'm using is as follows:

With wordDoc.MailMerge
.OpenDataSource Name:=strSourcePath, Connection:="Entire
Spreadsheet", SQLStatement:=strSQL, SubType:=wdMergeSubTypeWord2000 '
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With


Is there another argument I could use for "Connection:", eg., "Visible
Range"

Any tips would be appreciated.

TIA, John