ComInterop With Office CommandBarButton Events

Brian Hormann <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.general
Message-ID <DOTNET%[email protected]>
I am having trouble getting the following word events to fire in my code.
What I am attempting to do is add a new menu item and then assign the
click event to a handler in my C# code and get this to fire when the user
clicks the menu item.

Here is the code sample:

_CommandBarButtonEvents_ClickEventHandler clickEventHandler = new
_CommandBarButtonEvents_ClickEventHandler(commandBarButtonClickHandler);

//Open an existing document.  Both the DocumentOpen and
//DocumentChange events will fire.
int commandBarControlType = 1;
string parameter = "My click Event";
Office.CommandBarButton cbControl = (Office.CommandBarButton)
app.CommandBars["File"].Controls.Add(commandBarControlType, Missing.Value,
parameter , Missing.Value, true);
cbControl.Caption = "BRIAN's Button";
bControl.Click += clickEventHandler;

I get other events to fire for the document opening, closing and changing
but I can not get the event to fire if it is prefixed with the "_".

What do I need to do to get this event to fire in my code.  Is there
something that I am doing incorrectly?

Brian Hormann - MCP
Interact Commerce Corp.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.