I'm having a very difficult time trying to create a macro that uses "Select recipients" in Mailings then selects "Use an existing list" and then points to a certain directory.
I tried record macro but that gives me nothing. So in other words I want my users to be able to just select a button and it points to a directory that contains csv files to merge the template to.
Whenever I assign this Macro to a Button in the QAT and I click it gives me "Argument Not Optional" However, If i run it in VBA it works.
Code:
Sub Merge()
'
' Merge Macro
'
'
Dialogs(wdDialogMailMergeOpenDataSource).Show
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Documents("C:\Documents\mytemplate.docm").Close SaveChanges:=wdDoNotSaveChanges
If Err.Number = 4160 Then
MsgBox "The file specified is not open.", vbCritical Or vbOKOnly, _
"File Not Open"
End If
On Error GoTo 0
End Sub
Any ideas or suggestions?
Thank you