Excel Events Conflict with VB and C# AddIns

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Hi,
I have two com addins running in Excel. One is written in VB and the
other in C#. Both addins are interested in the Workbookopen event.
When the event is triggered the c# code captures the event but the VB
code does not. If i disable the c# addin then the vb code works. Looks
like the c# addin is somehow blocking the vb events.

Anyone know how to fix this?

Many thanks,
Andy
 
There is only one WorkbookOpen event, so once one add-in hooks it, there
is nothing for the other one to hook.

If you are hooking the WorkbookOpen event in your add-ins, this is
likely your problem.

You may need to create a public function in each of your add-ins that
executes the code, and CALL those functions from Excel's Workbook_Open
event in the ThisWorkbook module.

It would be something like this (which is from the VB Help file):
' Call a Microsoft Windows DLL procedure. The Declare statement must be
' Private in a Class Module, but not in a standard Module.
Private Declare Sub MessageBeep Lib "User" (ByVal N As Integer)
Sub CallMyDll()
Call MessageBeep(0) ' Call Windows DLL procedure.
MessageBeep 0 ' Call again without Call keyword.
End Sub

In this example, MessageBeep is the name of the function in the file
user.dll, and two ways of calling it are shown.

Hope This Helps!


Mike Argy
Custom Office solutions and
Windows/UNIX applications
 
Back
Top