RemoveDocument Method
Removes the active document from the shared workspace.
expression.RemoveDocument()
expression Required. An expression that returns a SharedWorkspace object.
Remarks
If the user does not have permission to remove the shared workspace document from the server, then the server copy remains intact, but the local copy of the document is disconnected from the shared workspace. In the case where the document has been opened directly from the workspace, then removed from the workspace using RemoveDocument, the document must be saved to another location before closing; otherwise, it will remain 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, then offers the user the option of removing the document from the workspace.
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 has been removed.", _
vbInformation + vbOKOnly, "Removed"
Else
MsgBox "Removal cancelled.", _
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