Udostępnij za pośrednictwem


COleDocObjectItem::ExecCommand

Call this member function to execute the command specified by the user.

HRESULT ExecCommand(
   DWORD nCmdID,
   DWORD nCmdExecOpt = OLECMDEXECOPT_DONTPROMPTUSER,
   const GUID* pguidCmdGroup = NULL 
);

Parameters

  • nCmdID
    The identifier of the command to execute. Must be in the group identified by pguidCmdGroup.

  • nCmdExecOpt
    Specifies command-execution options. By default, set to execute the command without prompting the user. See OLECMDEXECOPT for a list of values.

  • pguidCmdGroup
    Unique identifier of the command group. By default, NULL, which specifies the standard group. The command passed in nCmdID must belong to the group.

Return Value

Returns S_OK if successful; otherwise,returns one of the following error codes.

Value

Description

E_UNEXPECTED

Unexpected error occurred.

E_FAIL

Error occurred.

E_NOTIMPL

Indicates MFC itself should attempt to translate and dispatch the command.

OLECMDERR_E_UNKNOWNGROUP

pguidCmdGroup is non-NULL but does not specify a recognized command group.

OLECMDERR_E_NOTSUPPORTED

nCmdID is not recognized as a valid command in the group pGroup.

OLECMDERR_DISABLED

The command identified by nCmdID is disabled and cannot be executed.

OLECMDERR_NOHELP

Caller asked for help on the command identified by nCmdID but no help is available.

OLECMDERR_CANCELLED

User canceled the execution.

Remarks

The pguidCmdGroup and the nCmdID parameters together uniquely identify the command to invoke. The nCmdExecOpt parameter specifies the exact action to take.

Requirements

Header: afxole.h

See Also

Reference

COleDocObjectItem Class

Hierarchy Chart

IOleCommandTarget::Exec

Other Resources

COleDocObjectItem Members