Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet_change event handler error gen Excel Discussion (Misc queries) 0 January 18th 08 04:55 AM
What code do I use to attach event handler that will open my user. TeresaManley Excel Worksheet Functions 2 May 5th 07 09:55 PM
Cell Event Handler David Excel Programming 3 January 19th 04 04:51 PM
Re : Excel event handler Worksheet_SelectionChange TKT-Tang Excel Programming 1 July 18th 03 08:27 AM
Re : Excel event handler Worksheet_SelectionChange TKT-Tang Excel Programming 1 July 16th 03 07:21 AM


All times are GMT +1. The time now is 08:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"