ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to make the opening of a workbook conditional upon the opening of another workbook (https://www.excelbanter.com/excel-programming/285523-how-make-opening-workbook-conditional-upon-opening-another-workbook.html)

Marcello do Guzman

How to make the opening of a workbook conditional upon the opening of another workbook
 
I have a main workbook named Homebase that has a password form. The
correct password must be entered to open the Homebase workbook.
Homebase has hyperlinks to module workbooks which have different names
(P&L Module, Cash Flow Module, etc.)

I want to make sure that users cannot open module workbooks unless the
Homebase workbook is already open.
If someone tried to do this a message box would appear that displays
the mesage: "Sorry, but you can only access this module through
Homebase." The module workbook would NOT open and Excel would be blank
when the user closes the message box.

I used the following code and cannot get it to work:

Sub Workbook_Open()

If Workbooks.Open("Home") = False Then

ThisWorkbook.Close

End If


Would appreciate any help with the VBA code that I would write in each
module workbook to do the above.


Respond via email:

Thanks in advance.


Marcello



Rocky McKinley

How to make the opening of a workbook conditional upon the opening of another workbook
 
Something like this might do it...

Sub Workbook_Open()
Dim WB As Workbook
For Each WB In Workbooks
If WB.Name = "Home.xls" Then GoTo HomeIsOpen
Next
ThisWorkbook.Close
HomeIsOpen:
End Sub

--
Regards,
Rocky McKinley


"Marcello do Guzman" wrote in message
...
I have a main workbook named Homebase that has a password form. The
correct password must be entered to open the Homebase workbook.
Homebase has hyperlinks to module workbooks which have different names
(P&L Module, Cash Flow Module, etc.)

I want to make sure that users cannot open module workbooks unless the
Homebase workbook is already open.
If someone tried to do this a message box would appear that displays
the mesage: "Sorry, but you can only access this module through
Homebase." The module workbook would NOT open and Excel would be blank
when the user closes the message box.

I used the following code and cannot get it to work:

Sub Workbook_Open()

If Workbooks.Open("Home") = False Then

ThisWorkbook.Close

End If


Would appreciate any help with the VBA code that I would write in each
module workbook to do the above.


Respond via email:

Thanks in advance.


Marcello






All times are GMT +1. The time now is 12:48 PM.

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