Using Excel as datasource for merge
Thanks Doug. This was helpful.
Mark
"Doug Robbins - Word MVP" wrote:
Running a macro with the following code would avoid that dialog from being
shown:
Dim fd As FileDialog
Dim strDataSource As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.Title = "Select the Data Source"
fd.InitialFileName = Environ("HomePath") & "\Documents\My Data Sources\"
fd.Filters.Add "Excel", "*.xls", 1
Dim vrtSelectedItem As Variant
With fd
If .Show = -1 Then
strDataSource = .SelectedItems(1)
Else
MsgBox "You have not selected a data source."
Set fd = Nothing
Exit Sub
End If
End With
Set fd = Nothing
SendKeys "{Enter}"
ActiveDocument.MailMerge.OpenDataSource (strDataSource)
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Markus" wrote in message
...
I would like to use Excel as the datasource for a merge. When I do, the
user
is presented with a dialog box asking them to pick a Sheet, even tho the
.xls
file has only one sheet in it.
Could someone help me withthe syntax that skips this dialog, or is it not
possible?
Many thanks,
Mark
.
|