CommandBeforeExecute 事件

       

在指定的命令被执行前,该事件发生。如果要在某命令执行前施加一些限制条件,则可以使用该事件。

Private Sub Form_CommandBeforeExecute(ByVal Command As Variant, ByVal Cancel As Object)

Command   将要执行的命令。

Cancel   将该对象的 Value 属性设为 True 会取消命令。

说明

OCCommandIdChartCommandIdEnumPivotCommandId 常量包含每个 Microsoft Office Web 组件的受支持命令的列表。

示例

下面的示例显示了捕获 CommandBeforeExecute 事件的子例程的语法。

Private Sub Form_CommandBeforeExecute( _
        ByVal Command As Variant, ByVal Cancel As Object)
    Dim intResponse As Integer
    Dim strPrompt As String

    strPrompt = "Cancel the command?"

    intResponse = MsgBox(strPrompt, vbYesNo)

    If intResponse = vbYes Then
        Cancel.Value = True
    Else
        Cancel.Value = False
    End If
End Sub