ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Misbehaving 'Worksheet_Open()' Event (https://www.excelbanter.com/excel-programming/284151-misbehaving-worksheet_open-event.html)

James[_14_]

Misbehaving 'Worksheet_Open()' Event
 
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?





Tom Ogilvy

Misbehaving 'Worksheet_Open()' Event
 
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" wrote in message
...
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?







James[_14_]

Misbehaving 'Worksheet_Open()' Event
 
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?

Tom Ogilvy

Misbehaving 'Worksheet_Open()' Event
 
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.

--
Regards,
Tom Ogilvy


"James" wrote in message
...
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?




Vasant Nanavati

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

--

Vasant


"James" wrote in message
...
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?





All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com