The following procedure shows how to use the Dial method to dial a modem that's available on a shared modem pool, to which you gain access via a Telnet connection. The procedure first disconnects the current connection (if any), and then configures and connects to the shared modem pool using Telnet. Once the connection is open, the macro waits for a password prompt from the modem pool, asks the user to provide the password using the PasswordBox method, and then tries to get the modem's attention with the AT command. If the modem responds with "OK", the Dial method is used to dial the phone number. The procedure tries three times to get the modem's attention; if the modem doesn't respond, the procedure starts again from the top, up to five times.

Sub UseDialToConnect ()

Dim CR As String

Dim tries As Integer, retries As Integer

Dim gotPrompt As Integer

Dim thePassword As String


CR = Chr$(rcCR)


With Session

If .Connected = True Then


End If

If .Connected = False Then

.ConnectionType = "TELNET"

.ConnectionSettings = "Host modempool"


End If


.Transmit CR

If .WaitForString("Password>", 5, rcAllowKeystrokes) = False Then

MsgBox("Couldn't get Telnet modem.")

Exit Sub

End If


thePassword = .PasswordBox("Enter password for Telnet modem: ")

If thePassword = "" Then

Exit Sub


.Transmit thePassword & CR

End If


gotPrompt = False

For tries = 1 To 3

.Transmit "at" & CR

gotPrompt = .WaitForString("OK", 3, rcAllowKeystrokes)

If gotPrompt = True Then

Exit For

End If



If gotPrompt = False Then

retries = retries + 1

If retries = 5 Then

MsgBox "Could not establish connection to the Telnet modem."

Exit Sub


Goto tryAgain

End If

End If


.Dial "217-0145", "Bulletin Board"

End With

End Sub