XLL+ Class Library (6.3)

CXlWorkbookBeforeCloseEventStaticObserver::Update

Respond to an event

virtual void Update(
   CXlBeforeCloseEventArgs* e
);

Parameters

e

A pointer to an event arguments object is sent to the Update method.

Remarks

Derived classes should implement this function, which is the event handler for the XLL+ event model.

Example

The code below defines a class derived from CXlWorkbookBeforeCloseEventStaticObserver, implements an Update method which is called when the event occurs, and instantiates an instance of the new class.

Note that this particular Update method uses CXlBeforeCloseEventArgs::SetCancel to cancel the event, and prevent the workbook from being closed.

CopyC++
// Define a class derived from CXlWorkbookBeforeCloseEventStaticObserver 
class CMyWorkbookCloseEventObserver : CXlWorkbookBeforeCloseEventStaticObserver
{
public:
    // This method will be called during the XlWorkbookBeforeClose event. 
    virtual void Update(CXlBeforeCloseEventArgs* e)
    {
        CXllApp::XlMessageBox(_T("Closing ") + e->GetBookName(), 
            XlMessageBoxTypeInformation);
        e->SetCancel(true);
    }
};

// Create an instance of the class
CMyWorkbookCloseEventObserver myWorkbookCloseObserver;

Requirements

Header: xlpevents.h

See Also

CXlWorkbookBeforeCloseEventStaticObserver Class | CXlWorkbookBeforeCloseEventStaticObserver Methods