Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workbook_Open problem 1

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
What is wrong with this code or if nothing is wrong what could be the reasons why this is not working? I can get it to work on every other Excel sheet but not this one. Argggg.

Sub Workbook_Open()
Sheets("Production Log").Protect userinterfaceonly:=True
UserForm4.Show
End Sub

P.S. No alarms come up nothing happens the form doesn't even show.

I may not be very smart but I'm sure wirey!!!!
 
I answered my own question. I suppose that the workbook_Open command should be in the Workbooks section and not a module? This works but I'm not sure why it has to be that way. Why doesn't this work in an Auto_Open sub?

I may not be very smart but I'm sure wirey!!!!
 
Sounds like you've come to Excel from Word.

AutoOpen and all the rest are exclusive to Word. The Workbook module is pre-built - event code for the workbook has to go in there.

 
Bry - Auto_Open and Auto_Close are both available in excel (legacy from xl95 - pre events)

BUT - they need the _ between them (just as I have written) - otherwise they will not be recognised on open or close
Ribhead
The workbook_open sub needs to be in the workbook module as it is an EVENT procedure and it therefore needs to be related to the object (ie the workbook)

Auto_Open and Auto_Close are generic subs, not events and therefore can be placed in a standard module

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
Get the best answers to your questions - faq222-2244
 
Ah, I stand corrected.

I guess that that would be one of those things that won't be removed from the functionality, but would only be available in teh help files if you turned the "hidden help" on?

 
Correct Bry - it's pretty hard to find anything on it in the help file - it was easier to find in '97 but I can't even find it in 2000
as I say, it's just a legacy thing really - workbook_open fires before auto_open anyway so there's no real bonus to using it - might as well use the wb_open event

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
Get the best answers to your questions - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top