MSHTML Methods: execCommandShowHelp

Scripting Syntax

bSuccess = object.execCommandShowHelp (sCommand);

Object

The execCommandShowHelp method applies to the document and TextRange objects and the controlRange collection.

Arguments

The required sCommand argument names a command to execute. There are many supported commands.

Return Value

The method returns true for success, else false.

Behaviour

The execCommandShowHelp method provides scriptable access to the object’s IOleCommandTarget functionality, specifically to call the Exec method but with execution options constrained to OLECMDEXECOPT_SHOWHELP.

The case-insensitive command name given as sCommand translates to a numeric command ID in the MSHTML command group represented programmatically by CGID_MSHTML. Even within this command group, only a small subset of the commands that are supported through the IOleCommandTarget interface are supported for scripting.

The queryCommandEnabled method fails if the given command name is not supported for scripting. For supported commands, the method becomes a call to Exec with no input or output and with OLECMDEXECOPT_SHOWHELP as the execution options. The success or failure of calling Exec becomes success or failure of the execCommandShowHelp method.

What happens in the call to Exec varies with the command and is anyway left for the different topic of MSHTML’s IOleCommandTarget functionality.

That said, the document implementation is known to fail all requests with OLECMDEXECOPT_SHOWHELP as the execution option, such that the execCommandShowHelp method always fails. Perhaps this is why Microsoft omits execCommandShowHelp from the HTML and DHTML Reference.

There is a demonstration here. To see it, please enable scripting and then refresh this page.

function Test_document_execCommandShowHelp ()
{
    var cmd = prompt ("Enter the name of an MSHTML command to execute for help:", "");
    if (cmd == null) return;

    var result = document.execCommandShowHelp (cmd);
    alert ('execCommandShowHelp ("' + cmd + '") for the document returned ' + result);
}