SharedWorkspace.RemoveDocument method (Office)

Removes the active document from the shared workspace site.

Note

Beginning with Microsoft Office 2010, this object or member has been deprecated and should not be used.

Syntax

expression.RemoveDocument

expression A variable that represents a SharedWorkspace object.

Remarks

If the user does not have permission to remove the shared workspace document from the server, the server copy remains intact, but the local copy of the document is disconnected from the shared workspace. In the case where the document was opened directly from the workspace and then removed from the workspace by using RemoveDocument, the document must be saved to another location before closing; otherwise, it remains in the workspace.

Use the Disconnect method to detach the local copy of the document from the shared workspace without removing the shared copy.

Example

The following example determines whether the active document is connected to a shared workspace, and then offers the user the option of removing the document from the workspace site.

    Dim r As Long 
    If ActiveWorkbook.SharedWorkspace.Connected Then 
        r = MsgBox("Are you sure you want to remove this document?", _ 
            vbQuestion + vbOKCancel, "Are you sure?") 
        If r = vbOK Then 
            ActiveWorkbook.SharedWorkspace.RemoveDocument 
            MsgBox "The document is removed.", _ 
                vbInformation + vbOKOnly, "Removed" 
        Else 
            MsgBox "Removal canceled.", _ 
                vbInformation + vbOKOnly, "Still In Workspace" 
        End If 
    Else 
        MsgBox "The active document is not connected to a shared workspace.", _ 
            vbInformation + vbOKOnly, "Not Connected" 
    End If 

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.