Excel events - please help!!!!

J

j23

How to catch excel events form C++ program? I have no idea?

Here is my code, I can connect to excel, create new workbook, but how to
connect my handler to Excel event?

HRESULT BeforeSave (VARIANT_BOOL SaveAsUI, VARIANT_BOOL *Cancel)
{
MessageBox(NULL, "Hello fro beforesave", "zzz", MB_OK);
*Cancel = false;
return 0;
}

{
_ApplicationPtr pXL;
try {
pXL.CreateInstance(L"Excel.Application");
pXL->Visible = VARIANT_TRUE;

pXL->EnableEvents = true;
WorkbooksPtr pBooks = pXL->Workbooks;
_WorkbookPtr pBook = pBooks->Add((long)xlWorksheet);

?????????
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top