queryCommandState Method

       

Returns a Boolean that indicates the state of the specified command. If True, the specified command has already been carried out on the current selection. If False, the specified command has not yet been carried out on the current selection.

expression.queryCommandState(cmdID)

expression   Required. An expression that returns a DispFPHTMLDocument object.

cmdID  Required. A String that specifies the command identifier.

Remarks

This method returns Null if the state of the current selection could not be determined.

Example

The following example prompts the user for a command identifier and displays a message based on the result of the method.

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