Automatically run a Macro when file opens?

A

AA

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 Tools>Protection, 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
 
P

Paul B

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 **
 
A

AA

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?
 
D

Don Guillett

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
 
A

AA

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top