ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable the opening of another workbook (https://www.excelbanter.com/excel-programming/283555-disable-opening-another-workbook.html)

DDLY

Disable the opening of another workbook
 
Dear all, I just would like to know how could I prevent the opening of second workbook while the first workbook is opened or in using. Great thanks!

Michel Pierron

Disable the opening of another workbook
 
Hi DDLY;

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnWindow = ""
End Sub

Private Sub Workbook_Open()
Application.OnWindow = ThisWorkbook.Name & "!ThisWbkOnly"
End Sub

In a standard module:
Sub ThisWbkOnly()
If Not ActiveWorkbook.Name = ThisWorkbook.Name Then
ActiveWorkbook.Close False
MsgBox "This session of Excel is reserved for the " & ThisWorkbook.Name
& " !"
End If
End Sub

MP

"DDLY" a écrit dans le message de
...
Dear all, I just would like to know how could I prevent the opening of
second workbook while the first workbook is opened or in using. Great
thanks!




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

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