View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Add-in to run macro when ANY workbook is opened?


You'll have to set a reference to the application object
AND monitor the application events. You could create a classmodule but
following is simpler.


in the addin's Thisworkbook object module:

Option Explicit

Dim WithEvents xlApp As Application

Private Sub Workbook_Open()
Set xlApp = Application
End Sub

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Target.Address < "$A$1" Then
Sh.Cells(1).Select
End If
End Sub


instantiate the xlapp variable by running the workbook_open procedure
(once) then try to navigate your workbooks :)


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


jruppert wrote :


i would like to create an add-in that runs when any workbook is opened.
I didnt think i could use the workbook_open code b/c that would have to
reside in the individual workbooks, am i wrong in that assumption?

thanks.