Add In Questions
An add-in is a workbook, albeit a special type of workbook. You don't attach
it to a workbook, it is available to the Excel application when installed,
and thus to all workbooks.
You can create worksheet events for all workbooks by creating application
events in the add-in. Here is some example code. First add a class module,
name it clsEventSink, and add this code
Option Explicit
Private WithEvents App As Application
Private Sub App_SheetActivate(ByVal Sh As Object)
'your code here
End Sub
Private Sub Class_Initialize()
Set App = Application
End Sub
Then in Thisworkbook, add this code
Option Explicit
Private cAppEvents As clsEventSink
Private Sub Workbook_Open()
Set cAppEvents = New clsEventSink
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
--
HTH
RP
(remove nothere from the email address if mailing direct)
"keithb" wrote in message
...
Here are a couple of questions about using Add-Ins:
How can I attach an Add-In to a Workbook using VBA?
Once the Add-In is attached, how do I associate the subroutines and
functions in the add-in with events taking place in the workbook.worksheet
where it is attached? For example an on_activate event in Sheet1 of the
workbook that has an add-in attached needs to run code that exists in the
add-in.
Thanks,
Keith
|