This procedure connects to the currently configured host if no connection exists. If a connection exists, a dialog box confirms whether the user wants to connect or disconnect.
Sub ConnectOrDisconnect()
Dim reply As Integer
With Session
If .Connected Then
reply = MsgBox("Disconnect from the host?", _
vbOKCancel, "Disconnect")
If reply = vbOK Then Session.Disconnect
Else
.Connect
End If
End With
End Sub