mailmerge recorded macro

D

daoustclaire9

Hello,

I recorded a macro for mailmerge, it works fine but...

I did use Filter when I recorded it but it doesn't show in the macro. Therefore there is no filtering.

I have tried adding SQL statement but it doesn't work. (not familiar with that)

Here is the code:

ActiveDocument.MailMerge.MainDocumentType _
= wdFormLetters
ActiveDocument.MailMerge.OpenDataSource _
Name:=fichier, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=fichier;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Lo", _
SQLStatement:="SELECT * FROM `'Caisse fusion$'`", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
ActiveDocument.MailMerge.DataSource.ActiveRecord _
= wdNextRecord
ActiveDocument.MailMerge.ViewMailMergeFieldCodes _
= wdToggle
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord

ir = ActiveDocument.MailMerge.DataSource.RecordCount
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = ir
End With
.Execute Pause:=False
End With


Any help would be appreciated.

Claire
 

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