Executes a command on the current document, current selection, or the given range.
HRESULT execCommand( BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet );
- [in] BSTR that specifies the command to execute. This command can be any of the command identifiers that can be executed in script.
- [in] VARIANT_BOOL that specifies one of the following values.
- Default. Do not display a user interface. Must be combined with value, if the command requires a value.
- Display a user interface if the command supports one.
- [in] VARIANT that specifies the string, number, or other value to assign. Possible values and possible VARIANT subtypes depend on the command.
- [out, retval] Pointer to a VARIANT_BOOL that returnsVARIANT_TRUE if the command is successful.
Returns S_OK if successful, or an error value otherwise.
Do not invoke the IHTMLControlRange::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 IHTMLControlRange interface using IID_IHTMLControlRange for the IID.