Does anyone know how to get a macro to run automatically everytime a file is opened? Thanks
Does anyone know how to get a macro to run automatically everytime a file is opened? Thanks
It seems to me like you can try to use an Application Open Workbook Event. This is straight out of the help section.
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
' your code here
End Sub
For Project, look at the Project.Open event
So I have opened my project, then opened VBE, navigated to the 'ThisProject' file, selected 'Project' from the object pick list and selected 'Open' from the event pick list. Ive then entered my code:
Private Sub Project_Open(ByVal pj As Project)
My Macro code
End sub
Then saved and closed my file but the macro doesnt run when I open the mpp file. Anyone an idea what Ive missed?
Does any code run at all? Msgbox? What are your macro security settings? Project 2010 disables all macros except signed -- you'll need to drop the setting.
Thanks for your advice. If I 'Enable all macros' my Open event works fine but I am aware that this setting is potentially dangerous so my next question is; How do I digitally sign the macro so that it will run if I raise my macro setting?
You can create a self-signing certificate. See:
http://office.microsoft.com/en-us/ex...010354312.aspx
The other option is to get a signing authority but that is much longer and may cost money.
I have created a self-signing certificate and all works fine. Thanks for your help.
You are welcome. Glad to know the self-signed certificate works.
Bookmarks