The following macro will attach the same data source - here "D:\My
Documents\Test\Names Data.doc"
to all the files in a folder selected from the dialog.
Dim fDialog As FileDialog
Dim DataFile As String
DataFile = "D:\My Documents\Test\Names Data.doc"
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select Folder containing the letters and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
DocDir = .SelectedItems.Item(1)
If Right(DocDir, 1) <> "\" Then DocDir = DocDir + "\"
End With
On Error Resume Next
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList <> ""
Documents.Open DocList
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource DataFile
End With
Documents.Close wdSaveChanges
DocList = Dir$()
Loop
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>