Addin - Look for a File when it is opened
There are application events that you can tie into.
Start a new workbook and put this in the ThisWorkbook Module:
Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub Workbook_Open()
Set xlApp = Application
End Sub
Private Sub Workbook_Close()
Set xlApp = Nothing
End Sub
Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
If LCase(Wb.Name) = LCase("hi there.xls") Then
MsgBox "Found it!"
End If
'or check using the path, too????
If LCase(Wb.FullName) = LCase("C:\my documents\excel\hi there.xls") Then
MsgBox "Right folder, too"
End If
End Sub
Then save this as an addin and either install it (tools|addins) or put it in
your XLStart folder.
(You'll have to explain to the users how to install it.)
Chad Cameron wrote:
Hi All,
I am not sure how to word this. I want to make an addin that monitors which
files are opened. When a particular file is open, then run a macro.
I don't want the marco in the file in question, because the people I send
the file too, see the message about a macro, and refuse to open it, or it
gets block.
I know I could call the macro from a button, but I thought having the marco
start when the file is opened would be easier.
Thanks
Chad
--
Dave Peterson
|