A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Automatically run a Macro when file opens?



 
 
Thread Tools Display Modes
  #1  
Old May 8th, 2004, 05:40 PM
AA
external usenet poster
 
Posts: n/a
Default Automatically run a Macro when file opens?

I have one worksheet in a workbook Protected, and I save the file that
way.

When I open the file again, the worksheet is no longer protected,
although if I select ToolsProtection, my only choice is "UnProtect
Worksheet...", so it thinks the worksheet is still protected. Maybe
it
is, but access to both locked and unlocked cells is allowed.

Ok, I don't understand this behavior, and I would like to. When the
other person who uses this file opens it, I don't want them using this
block of cells.

So I figured I could work around it by running an AutoOpen macro,
like you can in Word, that would re-Protect that worksheet. Except
that a macro entitled "sub AutoOpen()" doesn't work.

How do I have a macro run automatically when I open an Excel file?

TIA,

Andy


  #2  
Old May 8th, 2004, 07:22 PM
Paul B
external usenet poster
 
Posts: n/a
Default Automatically run a Macro when file opens?

Use the work book open event, put it in thisworkbook code
Private Sub Workbook_Open()
' Your code here
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"AA" wrote in message
...
I have one worksheet in a workbook Protected, and I save the file that
way.

When I open the file again, the worksheet is no longer protected,
although if I select ToolsProtection, my only choice is "UnProtect
Worksheet...", so it thinks the worksheet is still protected. Maybe
it
is, but access to both locked and unlocked cells is allowed.

Ok, I don't understand this behavior, and I would like to. When the
other person who uses this file opens it, I don't want them using this
block of cells.

So I figured I could work around it by running an AutoOpen macro,
like you can in Word, that would re-Protect that worksheet. Except
that a macro entitled "sub AutoOpen()" doesn't work.

How do I have a macro run automatically when I open an Excel file?

TIA,

Andy




  #3  
Old May 8th, 2004, 07:35 PM
AA
external usenet poster
 
Posts: n/a
Default Automatically run a Macro when file opens?

I figured out the AutoOpen part.

It's Auto_Open.


  #4  
Old May 8th, 2004, 07:36 PM
AA
external usenet poster
 
Posts: n/a
Default Automatically run a Macro when file opens?

Use the work book open event, put it in thisworkbook code
Private Sub Workbook_Open()
' Your code here
End Sub


I used Auto_Open. Does Workbook_Open act differently?


  #5  
Old May 8th, 2004, 10:44 PM
Don Guillett
external usenet poster
 
Posts: n/a
Default Automatically run a Macro when file opens?

Auto_open is a throwback to the old days. It will work but not when you open
with a macro UNLESS you tell it to.
Workbook_Open goes in the ThisWorkbook module accessed easily by right click
on the excel icon in the upper left
next to FILE

--
Don Guillett
SalesAid Software

"AA" wrote in message
...
Use the work book open event, put it in thisworkbook code
Private Sub Workbook_Open()
' Your code here
End Sub


I used Auto_Open. Does Workbook_Open act differently?




  #6  
Old May 9th, 2004, 04:06 AM
AA
external usenet poster
 
Posts: n/a
Default Automatically run a Macro when file opens?

Auto_open is a throwback to the old days. It will work but not when you open
with a macro UNLESS you tell it to.
Workbook_Open goes in the ThisWorkbook module accessed easily by right click
on the excel icon in the upper left
next to FILE


Ok, I moved and renamed it.

Thanks!


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:31 PM.


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