ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro On Open (https://www.excelbanter.com/excel-programming/389850-macro-open.html)

[email protected]

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

PCLIVE

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




Dave Peterson

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

moon

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




[email protected]

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






All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com