Disconnect Method

Microsoft Office Visual Basic

Disconnect Method

Disconnects the local copy of the active document from the shared workspace.

expression.Disconnect()

expression    Required. An expression that returns a SharedWorkspace object.

Remarks

Use the Disconnect method to detach the local copy of the active document from the shared workspace. This method leaves the shared document on the server; however, the local copy will no longer be synchronized with the shared copy and will no longer benefit from the other collaboration features of the shared workspace. Use the RemoveDocument method to remove the shared document from the server.

Example

The following example determines whether the active document is connected to a shared workspace, then offers the user the option of disconnecting it.

        Dim r As Long
    If ActiveWorkbook.SharedWorkspace.Connected Then
        r = MsgBox("Are you sure you want to disconnect this document?", _
            vbQuestion + vbOKCancel, "Are you sure?")
        If r = vbOK Then
            ActiveWorkbook.SharedWorkspace.Disconnect
            MsgBox "The document has been disconnected.", _
                vbInformation + vbOKOnly, "Disconnected"
        Else
            MsgBox "Disconnect cancelled.", _
                vbInformation + vbOKOnly, "Still Connected"
        End If
    Else
        MsgBox "The active document is not connected to a shared workspace.", _
            vbInformation + vbOKOnly, "Not Connected"
    End If