Sets the name of an add-in function to handle a specific COM event
[C++]
void SetComEventHandler(
int nEvent,
const char* pszMacroName
);
An integer representing the event to be handled. See Remarks below for a list of values.
The name of the macro function that will be called when the event occurs. The parameter should be set to NULL or an empty string to switch off event handling for this event.
This function sets the name of an add-in function that will be called whenever the
specified COM event occurs. If it is set to the name of an add-in function with the appproriate signature,
the function will be called.
If the function name is set to an empty string then no
special error handling will occur.
Note: COM event handlers will not be called unless
the SinkEvents flag has been set to TRUE, using
CXllApp::SetSinkEvents(TRUE).
The table below describes the events and the signatures
of the functions that handle them.
You can find a set of example functions with the correct signatures
in the ComEvents sample.
The following restrictions and notes also apply to
event handler callback functions: For more details about these events, see Excel Help
for the events of the Application object.
Event
Return value
Argument 1
Argument 2
NewWorkbook
(ignored)
const char* WorkbookName
SheetSelectionChange
(ignored)
const char* WorksheetName
const char* Range
SheetBeforeDoubleClick
BOOL Cancel
const char* WorksheetName
const char* Range
SheetBeforeRightClick
BOOL Cancel
const char* WorksheetName
const char* Range
SheetActivate
(ignored)
const char* WorksheetName
SheetDeactivate
(ignored)
const char* WorksheetName
SheetCalculate
(ignored)
const char* WorksheetName
SheetChange
(ignored)
const char* WorksheetName
const char* Range
WorkbookOpen
(ignored)
const char* WorkbookName
WorkbookActivate
(ignored)
const char* WorkbookName
WorkbookDeactivate
(ignored)
const char* WorkbookName
WorkbookBeforeClose
BOOL Cancel
const char* WorkbookName
WorkbookBeforeSave
BOOL Cancel
const char* WorkbookName
BOOL bSaveAsUI
WorkbookNewSheet
{ignored)
const char* WorkbookName
const char* WorksheetName
Header: xllplus.h
CXllApp Class
| CXllApp Methods
| CXllApp::GetComEventHandler()
| CXllApp::SetSinkEvents()
| ComEvents sample