Workbook_Open does not run for Addin

L

lightsaber777

I have an addin which handles events for certain workbooks. It makes
itself available through a menu bar. During the process of opening a
new workbook, it is supposed to catch the Workbook_open event and
check if the workbook being opened is something it should handle, if
it is, the menu is shown, if not, it does nothing. The addin also
handles other events such as double clicking on cells .

After some period of using the workbook with the addin enabled, it
seems to just stop handling events. I am checking that
Application.EnableEvents is still true and it is. But all events are
unhandled, including(it seems) workbook_open. Now, the workbook_open
event that is defined is in the addin's workbook... but it seems to
handle everything most of the time.

If anyone can give me a hint at what to look for I would appreciate
it. Sorry, I can't really post the code due to length and corporate
restriction. I'm just trying to figure out if there's a VBA guru out
there that has seen this sort of behavior before.

Thanks
 
L

lightsaber777

The workbook open event in an addin catches when the addin is opened, not
when other files are opened. That is similar to the workbook open event in a
regular workbook. You need to catch applicition level events. Check out this
link.

http://www.cpearson.com/excel/AppEvent.aspx

Thanks for that info. This workbook_open event *does* work most of
the time as it is. According to your post, it shouldn't work at all.
Any idea why it does?
 
J

Jim Thomlinson

I have not seen what you are describing. A workbook can catch it's own events
but not events in other workbooks from my experience. That is true regardless
whether it is a regular workbook or an addin. When you instantiate a new
Excel object as described in the link I posted, it is at the application
level and not the workbook level, so it can listen for events in any workbook.
 

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