Excel (2002) automation - ComException when trying to add an event.

T

Thibault

Hi everyone,

I'm running against a problem since a couple of days and can't figure
out a solution.
To make it simple, I'm trying to execute the code provided by the
Microsoft Help and Support website: http://support.microsoft.com/kb/303018
..
I'm compiling the code with Visual Studio 2008 under Windows XP
Professional SP2.
I have Office XP (2002) SP3 installed and the Office XP PIA DLL.

It compiles but when I run it I get this exception:
"System.Runtime.InteropServices.COMException with an HRESULT of
0x80040202".

It appears when the code tried to add an event to a CommandBarButton:

---
Office._CommandBarButtonEvents_ClickEventHandler oButtonHandler =
new Office._CommandBarButtonEvents_ClickEventHandler(oButton_Click);
oButton.Click += oButtonHandler; //Thrown exception
---

I tried the same code on another machine with Office 2007 and PIA dll
(v12) installed
and it works perfectly! It should also work for Office XP according
the 'how to'.

I searched everywhere about this topic but did not find any
solution...
I already ask this question on the Microsoft CLR forum where I've been
told that a value could be wrong in the WinError.h SDK file...

Any help will be greatly appreciated!
Thanks in advance.
 

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