返回 Boolean 类型的值,表明指定命令的状态。如果为 True,则已经在当前所选内容上执行了指定的命令。如果为 False,则尚未在当前所选内容上执行指定命令。
expression.queryCommandState(cmdID)
expression 必选。返回 DispFPHTMLDocument 对象的表达式。
cmdID 必选。String 类型。指定命令标识符。
如果不能确定当前所选内容的状态,则该方法返回 Null。
下列示例提示用户输入命令标识符,并根据方法的执行结果显示一条消息。
Sub QueryCommand()
'Determines whether a command has been carried out
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, checks command status and displays results.
If objDoc.queryCommandState(cmdID:=strUser) = True Then
MsgBox "The command " & strUser & _
" has already been carried out."
Else
MsgBox "The command " & strUser & _
" has not yet been carried out."
End If
End Sub