Sheila Yau
New Member
- Joined
- Nov 29, 2006
- Messages
- 20
Hi,
I have a workbook that may be used in "shared workbook" mode by users when it is open. I am trying to work out the code so that it cannot stay in this mode when the workbook is closed.
This is the code I have so far:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ActiveWorkbook.MultiUserEditing Then GoTo WrongMode
WrongMode:
MsgBox ("Please come out of shared workbook mode before closing the file")
ActiveWorkbook.ExclusiveAccess
End Sub
Is it possible to amend it so it selects "yes" to exclusive access? essentially I don't want a user to be able to close it in sharedworkbook mode. Otherwise other code will not work when the file is opened.
Thanks in advance for your help
Sheila
I have a workbook that may be used in "shared workbook" mode by users when it is open. I am trying to work out the code so that it cannot stay in this mode when the workbook is closed.
This is the code I have so far:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ActiveWorkbook.MultiUserEditing Then GoTo WrongMode
WrongMode:
MsgBox ("Please come out of shared workbook mode before closing the file")
ActiveWorkbook.ExclusiveAccess
End Sub
Is it possible to amend it so it selects "yes" to exclusive access? essentially I don't want a user to be able to close it in sharedworkbook mode. Otherwise other code will not work when the file is opened.
Thanks in advance for your help
Sheila