Disable the opening of another workbook

  • Thread starter Thread starter DDLY
  • Start date Start date
D

DDLY

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!
 
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" <[email protected]> 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!
 
Back
Top