How to check whether the current user has been removed from the shared workbook?

与世无争的帅哥 提交于 2019-11-29 12:04:28

I have come across a temporary fix. I use a command (ShowConflictHistory) which returns an error when you have been kicked out of the document, then I use error handling techniques to save a unique copy;

On Error GoTo Errhandler:
If ActiveWorkbook.ShowConflictHistory = False Or True Then 'This returns Err 1004 if the person has been kicked from the workbook, so it can be handled accordingly in ErrHandler.
End If

Continue1: 
On Error Resume Next

'''''''''
'Main code section
'''''''''

Exit Sub

Errhandler:

Select Case Err
     Case 1004: 'The error which results if you've been kicked out of the document.
        Call SaveCopyOfShared
        Exit Sub    
     Case Else:
        GoTo Continue1:
End Select

End Sub

If someone comes up with a more conventional solution. Please let me know.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!