queryCommandSupported 方法

       

返回 Boolean 类型值,表示当前选择是否支持指定的命令。

expression.queryCommandSupported(cmdID)

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

cmdID  必选,String 类型。代表指定的命令标识符。

示例

以下示例提示用户输入命令标识符。根据操作的结果向用户显示一条消息。

Sub QueryCommand()
'Determines whether a command is supported
'by the current selection

    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.")
    'Run the associated command
    If objDoc.queryCommandSupported(cmdID:=strUser) = True Then
        'If yes - display message.
        MsgBox "The command " & strUser & _
               " is supported by the current selection."
    Else
        'If no - display message.
        MsgBox "The command " & strUser & _
               " is not supported by the current selection."
    End If

End Sub