Check whether the current user has been removed (kicked) from the shared workbook?

liewelulu

New Member
Joined
Nov 6, 2014
Messages
1
I have a shared document which runs various commands upon close. This includes saving normally (if document is still shared) and saving as shared (if document was unshared).
The problem arises when a person left the document open for a while then close it. The document automatically overrides the current document (if the document was made unshared, or it gives the option to overide when the .save command runs) and the data which was entered meanwhile is potentially lost.
How do I check if the user is removed from the document, so that the saving section can be skipped if that's the case?
[HR][/HR][HR][/HR]

<code>Private Sub Workbook_BeforeClose(Cancel As Boolean) </code>
[HR][/HR]<code>For i = 1 To Sheets.Count </code>[HR][/HR]<code></code><code> If Sheets(i).ProtectContents = False Then</code><code> </code>[HR][/HR]<code>Call Protect_Sheets 'Protects all the sheets</code><code> </code>[HR][/HR]<code>End If</code><code> </code>[HR][/HR]<code>Next i</code><code></code><code> </code>[HR][/HR]<code></code>[HR][/HR]<code>If ActiveWorkbook.ProtectStructure = False Then</code><code> </code>[HR][/HR]<code>Call Protect_Workbook 'Protects the workbook</code><code> </code>[HR][/HR]<code>End If</code><code></code><code> </code>[HR][/HR]<code></code>[HR][/HR]<code>If ActiveWorkbook.MultiUserEditing = False Then</code><code> </code>[HR][/HR]<code>Call SaveAsShared 'Saves the workbook as shared (overrides)</code><code> </code>[HR][/HR]<code>Else</code><code> ActiveWorkbook.Save 'Only saves as normal when the document was shared upon close (but defaults the current document name (which will override when no attention is paid))</code><code> </code>[HR][/HR]<code>End If</code>[HR][/HR]<code></code><code></code><code></code>[HR][/HR]<code>End Sub</code>[HR][/HR]<code></code><code></code>[HR][/HR]<code></code>If possible, I want another 'If' (just before calling the SaveAsShared function), which terminates the Sub when the user has been removed from the workbook. Any help will be much appreciated! Thanks in advance!
Lou

 

Forum statistics

Threads
1,085,495
Messages
5,383,997
Members
401,871
Latest member
allemandi

Some videos you may like

This Week's Hot Topics

Top