Thanks for writing.
The Mail Merge toolbar buttons are kind of hard to see and not very obvious.
Through trial and error and reading other internet posts, this is what I have for my button 1 (Open Data Source):
Private Sub cmdSelectDataSource_Click()
'select data source-step 1
Dim DataDoc As String
Dim MergeDoc As Document
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.Title = "Select data source and click OK"
.InitialFileName = "Rpt- Governance Reporting Projects.xls"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
.Filters.Clear
.Filters.Add "Excel", "*.xl*", 1
If .Show -1 Then
MsgBox "Cancelled By User", , Title
Exit Sub
End If
DataDoc = fDialog.SelectedItems.Item(1)
End With
ActiveDocument.MailMerge.OpenDataSource Name:=DataDoc, ConfirmConversions:=False, Format:=wdOpenFormatAuto, Connection:="Entire Spreadsheet", SubType:=wdMergeSubTypeWord2000
End Sub
This is what I have for button 3 (Merge New Document)
Private Sub cmdMergeDocument_Click()
'merge document-step 3
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
Me.cmdSelectDataSource.Enabled = False
Me.cmdMergeDocument.Enabled = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Me.cmdSelectDataSource.Enabled = True
Me.cmdMergeDocument.Enabled = True
End Sub
I don't know how to hide the command buttons, but I disabled them.
So I still need help with creating a button to open the Choose Recipients dialog box. Also,I still need help with protecting the form.
Thanks!
Quote:
Originally Posted by Doug Robbins - Word MVP
|