Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Excel file from VB and open MACRO no1jimmyman Excel Discussion (Misc queries) 0 February 14th 11 10:10 PM
Macro runs upon wkbk open, but no Workbook_Open or Auto_Open Macro Ron Coderre Excel Programming 2 September 26th 06 05:50 PM
Open workbook macro- find correct month to open? buzzharley[_10_] Excel Programming 8 July 8th 06 04:30 AM
open up an excel program with an auto open macro [email protected] Excel Programming 2 July 17th 05 04:48 PM
How do I get my personal macro worksheet to open whenever I open . Claudia_R Excel Discussion (Misc queries) 3 December 9th 04 11:59 PM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"