Code for mail merge to reference saved excel file
I am trying to get a code that will open a data source for mail merge and let you choose which source and path you want at that time. I can get the macro to work referencing a specific path such as Name="C:mydocuments\personal\etc...." but I need one that will let me select from different saved files. Here is what I have currently:
Sub LOTO_PRINT_TAGS()
'
' LOTO_PRINT_TAGS Macro
'
'
Dim sPath As String
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource sPath
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
|