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

后端 未结 1 1242
挽巷
挽巷 2020-12-20 02:31

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).

相关标签:
1条回答
  • 2020-12-20 02:52

    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.

    0 讨论(0)
提交回复
热议问题