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?




<code>Private Sub Workbook_BeforeClose(Cancel As Boolean) </code>

<code>For i = 1 To Sheets.Count </code>
<code></code><code> If Sheets(i).ProtectContents = False Then</code><code> </code>
<code>Call Protect_Sheets 'Protects all the sheets</code><code> </code>
<code>End If</code><code> </code>
<code>Next i</code><code></code><code> </code>
<code></code>
<code>If ActiveWorkbook.ProtectStructure = False Then</code><code> </code>
<code>Call Protect_Workbook 'Protects the workbook</code><code> </code>
<code>End If</code><code></code><code> </code>
<code></code>
<code>If ActiveWorkbook.MultiUserEditing = False Then</code><code> </code>
<code>Call SaveAsShared 'Saves the workbook as shared (overrides)</code><code> </code>
<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>
<code>End If</code>
<code></code><code></code><code></code>
<code>End Sub</code>
<code></code><code></code>
<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

 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top