ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook Open event (https://www.excelbanter.com/excel-programming/317961-workbook-open-event.html)

Libby

Workbook Open event
 
Hi

I have two workbooks called Book1 and Book2

Book2 has a password to open and is readonly

When I open Book1 from Book2, the Workbook_Open event in Book2 doesn't run,
or it runs but doesn't have any effect, even if I step through it. No error
messages appear, it just doesn't work.

The code is as follows
'Book1
Sub Workbook_Open
Workbooks.Open "path to book2",,,open password
ThisWorkbook.close
end sub

'Book2
Sub Workbook_Open
msgbox ok
Call ShowSheets 'macro stored in Module1 which
'unhides hidden sheets
sheet3.name = "Success"
end sub

The reason I want to open one workbook from another like this is because
unless the main workbook, Book2, is password to open, it can be opened in
Word and all the veryhidden sheets viewed. Hence I password to open Book2 and
use another Workbook that doesn't contain any hidden sheets to open it.

I'm using xl97
Thanks in advance

Tom Ogilvy

Workbook Open event
 
Why not take out the workbook_Open event in Book2 and have all the code you
need to run in Book1 with proper references so it works on the right book.

then have book1 open book2 and process it, then close itself.

--
Regards,
Tom Ogilvy


"Libby" wrote in message
...
Hi

I have two workbooks called Book1 and Book2

Book2 has a password to open and is readonly

When I open Book1 from Book2, the Workbook_Open event in Book2 doesn't

run,
or it runs but doesn't have any effect, even if I step through it. No

error
messages appear, it just doesn't work.

The code is as follows
'Book1
Sub Workbook_Open
Workbooks.Open "path to book2",,,open password
ThisWorkbook.close
end sub

'Book2
Sub Workbook_Open
msgbox ok
Call ShowSheets 'macro stored in Module1 which
'unhides hidden sheets
sheet3.name = "Success"
end sub

The reason I want to open one workbook from another like this is because
unless the main workbook, Book2, is password to open, it can be opened in
Word and all the veryhidden sheets viewed. Hence I password to open Book2

and
use another Workbook that doesn't contain any hidden sheets to open it.

I'm using xl97
Thanks in advance





All times are GMT +1. The time now is 04:48 AM.

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