全部显示

MailMergeWizardStateChange 事件

       

当用户从“邮件合并向导”的一个指定步骤变更到另一指定步骤时,该事件发生。

Private Sub object_MailMergeWizardStateChange(ByVal Doc As Document, FromState As Long, ToState As Long, Handled As Boolean)

object  在类模块事件中声明的 Application 类型对象。有关使用 Application 对象事件的详细信息,请参阅使用 Application 对象事件

Doc  邮件合并主文档。

FromState  用户目前所处的“邮件合并向导”步骤。

ToState  用户将变更至的“邮件合并向导”步骤。

Handled  如果该参数值为 True,则用户变更至下一步骤。如果该参数值为 False,则用户仍处于当前的步骤。

示例

该示例在用户从“邮件合并向导”的步骤三变更至步骤四时,显示一条消息。根据对该消息的响应,用户将变更至步骤四或保持在步骤三。该示例假定在一般声明中声明了一个名为 MailMergeApp 的应用程序变量,并将 Word Application 对象赋给该变量。

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