Is it possible to have a workbook to open on its on instance, and not allow other workbooks to open on it?
I have been searching around, found the code bellow,, but not sure how "Continue_Open" sub (that would be called from WorkBook_Open... that would be Called).
Private WithEvents oAppEvents As Application
Private oWb As Workbook
Private Sub Workbook_Open()
Dim oNewApp As New Application
If Application.Workbooks.Count > 1 Then
Me.ChangeFileAccess xlReadOnly
oNewApp.Workbooks.Open Me.FullName
oNewApp.Visible = True
Me.Close False
End If
Set oAppEvents = Application
End Sub
Private Sub oAppEvents_NewWorkbook(ByVal Wb As Workbook)
Dim oNewApp As New Application
Wb.Close False
oNewApp.Workbooks.Add
oNewApp.Visible = True
End Sub
Private Sub oAppEvents_WorkbookOpen(ByVal Wb As Workbook)
If Wb Is Me Then Exit Sub
Set oWb = Wb
oWb.ChangeFileAccess xlReadOnly
Application.OnTime Now, Me.CodeName & ".CloseWB"
End Sub
Private Sub CloseWB()
Dim oNewApp As New Application
oNewApp.Workbooks.Open oWb.FullName
oNewApp.Visible = True
oWb.Close False
End Sub
WorkBook_Open should call this subroutine (but only after it has been opened on it own instance).
Sub Continue_Open()
' do whatever the program is intended to do
UserForm1.Show
End Sub
Thanks
Ernesto
Bookmarks