![]() |
different IDispatch in event handler
Hello
I work on a com dll that is called from vba and manipulates a workbook. When catching the Workbook.SheetActivate event Excel passes the IDispatch interface of the activated sheet. I then try to compare it to a previously stored _Worksheet interface after querying it for IDispatch. However this never succeeds. One thing I cannot understand is that if I first query the passed IDispatch for the _Worksheet interface everything works as expected. The IDispatch interface is different from the original one passed to the event handler. void EventHandler::OnSheetActivate(IDispatchPtr sheet) { // IDispatchPtr does automatic QueryInterface Excel::_WorksheetPtr ws = sheet; // ws is different from sheet sheet = ws; // sheet is equal to ws and different from initial value ??? // now compare sheet to stored pointer // compare succeeds // if the conversion stuff above is omitted I never find a match for the stored pointer // Note: sheet could also be chart, code to handle this case is not included for brevity } Thanks |
All times are GMT +1. The time now is 11:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com