W
Worksmart
I am not a programmer but I know how to record macros. I’m working in Word
2003. The code below will give you a chuckle to start your weekend.
Scenario: Users will click a Command Button in a Word document to merge the
same database with various documents that are already set up with merge
fields.
When they click the button, a message box “Are You Sure?†pops up in case
they clicked the box in error. After that, they are given the opportunity to
browse for the document they want to merge (database and merge fields already
in place). After that, I’d like them to be able to choose the recipients
because they will not always need to create a document for everyone. Then on
to complete the merge, creating new documents (so they can view before
printing).
Below is the code I have so far. It works until I browse to find the file.
Merge doesn’t happen, and I have no idea what to do about them choosing
recipients.
Can someone help with this? Thanks in advance.
Private Sub CommandButton4_Click()
' Events_TentCard Macro
' Macro recorded 5/11/2008 by Peggy Duncan
'
If MsgBox(Prompt:="Are You Sure?", Buttons:=vbYesNo + vbQuestion, _
Title:="Mail Merge Document") = vbNo Then
Exit Sub
End If
Dialogs(wdDialogFileOpen).Show
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
'
End Sub
2003. The code below will give you a chuckle to start your weekend.
Scenario: Users will click a Command Button in a Word document to merge the
same database with various documents that are already set up with merge
fields.
When they click the button, a message box “Are You Sure?†pops up in case
they clicked the box in error. After that, they are given the opportunity to
browse for the document they want to merge (database and merge fields already
in place). After that, I’d like them to be able to choose the recipients
because they will not always need to create a document for everyone. Then on
to complete the merge, creating new documents (so they can view before
printing).
Below is the code I have so far. It works until I browse to find the file.
Merge doesn’t happen, and I have no idea what to do about them choosing
recipients.
Can someone help with this? Thanks in advance.
Private Sub CommandButton4_Click()
' Events_TentCard Macro
' Macro recorded 5/11/2008 by Peggy Duncan
'
If MsgBox(Prompt:="Are You Sure?", Buttons:=vbYesNo + vbQuestion, _
Title:="Mail Merge Document") = vbNo Then
Exit Sub
End If
Dialogs(wdDialogFileOpen).Show
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
'
End Sub