Misbehaving 'Worksheet_Open()' Event

J

James

I have some code in the 'Workbook_Open()' Event to unprotect a worksheet when the workbook opens.

It does what's expected of it when the workbook is opened 'manually', but I'm surprised & distressed to find that it doesn't work when the workbook is opened programmaticaly (i.e. Workbooks.Open "filename").

I'm using Excel 97. Is this unique to me, Excel 97, or all versions of Excel?

Can anyone shed some light?
 
T

Tom Ogilvy

If you are opening the workbook programmatically by using a shortcut key
combination that includes a Shift key, then that is the source of the
problem. Make the shortcut combination just control and a lowercase letter.

Unlike Auto_Open, the Workbook_Open event will fire when the file is opened
programmatically unless events have been disabled.

--
Regards,
Tom Ogilvy


James said:
I have some code in the 'Workbook_Open()' Event to unprotect a worksheet when the workbook opens.

It does what's expected of it when the workbook is opened 'manually', but
I'm surprised & distressed to find that it doesn't work when the workbook is
opened programmaticaly (i.e. Workbooks.Open "filename").
 
J

James

Thanks Tom

Unfortunately I'm not using a shortcut key - it's just a straightforward Sub in a standard code module

The code is executing perfectly except for unprotect the worksheet

Any other offers?
 
T

Tom Ogilvy

The code is executing perfectly except for unprotect the worksheet.

That isn't what you said originally:
that it doesn't work when the workbook is opened programmaticaly (i.e.
Workbooks.Open "filename").

So it would be hard to make any additional offers unless someone just wanted
to guess at what the real situation is.
 
V

Vasant Nanavati

A Workbook_Open() event cannot be in a standard module. Perhaps that is the
source of your problem.
 
Top