queryCommandEnabled 方法

       

返回 Boolean 类型的值,该值表明指定的命令是否可以执行。命令是否可以执行决定于文档的当前状态。有关当前文档的状态的详细信息,请参阅文档的 readyState 属性。

expression.queryCommandEnabled(cmdID)

expression  必选。返回“应用于”列表中的对象之一的表达式。

cmdID  必选。String 类型。代表命令标识符。

示例

下列示例提示用户输入命令标识符。queryCommandEnabled 方法使用用户的输入执行,根据方法的执行结果向用户显示一条消息。

Sub QueryCommand()
'Determines if a command can be executed
'based on the document state.

    Dim objApp As FrontPage.Application
    Dim objDoc As DispFPHTMLDocument
    Dim strUser As String

    Set objApp = FrontPage.Application
    Set objDoc = objApp.ActiveDocument
    'Prompt user to enter command name.
    strUser = InputBox("Enter a command identifier to be executed.")
    'Attept to run the associated command
    If objDoc.queryCommandEnabled(cmdID:=strUser) = True Then
        'If yes - display message.
        MsgBox "The command " & strUser & " can be executed."
    Else
        'If no - display message.
        MsgBox "The command " & strUser & " cannot be executed."
    End If

End Sub