편집

다음을 통해 공유


Application.MailMergeWizardStateChange event (Word)

Occurs when a user changes from a specified step to a specified step in the Mail Merge Wizard.

Syntax

expression.MailMergeWizardStateChange (Doc, FromState, ToState, Handled)

expression A variable that represents an Application object.

For information about using events with the Application object, see Using events with the Application object.

Parameters

Name Required/Optional Data type Description
Doc Required Document The mail merge main document.
FromState Required Long The Mail Merge Wizard step from which a user is moving.
ToState Required Long The Mail Merge Wizard step to which a user is moving.
Handled Required Boolean True moves the user to the next step. False for the user to remain at the current step.

Example

This example displays a message when a user moves from step three of the Mail Merge Wizard to step four. Based on the answer to the message, the user will either move to step four or remain at step three. This example assumes that you have declared an application variable called MailMergeApp in your general declarations and have set the variable equal to the Word Application object.

Private Sub MailMergeApp_MailMergeWizardStateChange(ByVal Doc As Document, _ 
 FromState As Long, ToState As Long, Handled As Boolean) 
 
 Dim intVBAnswer As Integer 
 FromState = 3 
 ToState = 4 
 
 'Display a message when moving from step three to step four 
 intVBAnswer = MsgBox("Have you selected all of your recipients?", _ 
 vbYesNo, "Wizard State Event!") 
 
 If intVBAnswer = vbYes Then 
 'Continue on to step four 
 Handled = True 
 Else 
 'Return to step three 
 MsgBox "Please select all recipients to whom " & _ 
 "you want to send this letter." 
 Handled = False 
 End If 
 
End Sub

See also

Application Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.