2 out of 3 rated this helpful - Rate this topic

IHTMLDocument2::execCommand Method

Executes a command on the current document, current selection, or the given range.

Syntax


HRESULT execCommand(
    BSTR cmdID,
    VARIANT_BOOL showUI,
    VARIANT value,
    VARIANT_BOOL *pfRet
);

Parameters

cmdID
[in] BSTR that specifies the command to execute. This command can be any of the command identifiers that can be executed in script.
showUI
[in] VARIANT_BOOL that specifies one of the following values.
VARIANT_FALSE
Default. Do not display a user interface. Must be combined with value, if the command requires a value.
VARIANT_TRUE
Display a user interface if the command supports one.
value
[in] VARIANT that specifies the string, number, or other value to assign. Possible values and possible VARIANT subtypes depend on the command.
pfRet
[out, retval] Pointer to a VARIANT_BOOL that returnsVARIANT_TRUE if the command is successful.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

Do not invoke the IHTMLDocument2::execCommand method until after the page loads.

The showUI and value parameters might be required depending on the command being executed.

This method is a wrapper function for the IOleCommandTarget::Exec method to enable scriptable execution of some command constants. IOleCommandTarget::Exec provides better performance and greater versatility than this method. You can obtain an IOleCommandTarget interface by calling QueryInterface on the IHTMLDocument2 interface using IID_IOleCommandTarget.

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ