Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro On Open
What code do I need to run a macro when a file is opened? The sub name is
PNL. Also, this file is password protected. Will that affect anything? Thanks Adam Bush |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro On Open
All+F11 to enter VB editor. Double-click ThisWorkbook.
Paste the following: Private Sub Workbook_Open() <Your Code Here End Sub I believe the code will run once the password is entered. Regards, Paul " m wrote in message ... What code do I need to run a macro when a file is opened? The sub name is PNL. Also, this file is password protected. Will that affect anything? Thanks Adam Bush |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro On Open
You could rename that sub to Auto_Open.
As long as it's in a General module (and there isn't an existing sub named Auto_Open), it should run. (and if the user allows macros to run) And if the user can open the workbook, I would bet that the password protection won't bother the macro. But you'll know for sure when you test it. wrote: What code do I need to run a macro when a file is opened? The sub name is PNL. Also, this file is password protected. Will that affect anything? Thanks Adam Bush -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro On Open
You should put an Auto_Open macro in a separate module. Make sure the name is Auto_Open. In there, you call your PNL-macro. Public Sub Auto_Open() Call PNL End Sub Private Sub PNL() MsgBox "This File is password protected" End Sub As soon the protection-password is entered, the macro will run. " m schreef in bericht ... What code do I need to run a macro when a file is opened? The sub name is PNL. Also, this file is password protected. Will that affect anything? Thanks Adam Bush |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro On Open
Thanks a lot Paul worked perfectly!
"PCLIVE" wrote: All+F11 to enter VB editor. Double-click ThisWorkbook. Paste the following: Private Sub Workbook_Open() <Your Code Here End Sub I believe the code will run once the password is entered. Regards, Paul " m wrote in message ... What code do I need to run a macro when a file is opened? The sub name is PNL. Also, this file is password protected. Will that affect anything? Thanks Adam Bush |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Open Excel file from VB and open MACRO | Excel Discussion (Misc queries) | |||
Macro runs upon wkbk open, but no Workbook_Open or Auto_Open Macro | Excel Programming | |||
Open workbook macro- find correct month to open? | Excel Programming | |||
open up an excel program with an auto open macro | Excel Programming | |||
How do I get my personal macro worksheet to open whenever I open . | Excel Discussion (Misc queries) |