Option Explicit
Private Declare Function tapiRequestMakeCall& Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$, ByVal CalledParty$, ByVal Comment$)
Public Sub Dial(Number As String, Name As String)
Dim lRES As Long
If Trim(Number) = "" Then
Exit Sub
End If
If MsgBox("About to call" & Trim(Name) & "at phone number" & Trim(Number) & vbCrLf & "Do it?") - vbYesNo = vbYes Then
lRES = tapiRequestMakeCall(Trim(Number), App.Title, Trim(Name), "")
Debug.Print Now; "Call->tapiRequestMakeCall Result code="; lRES; ""
End Sub
Private Sub cmdDial_Click()
Dim buff As String
Dim nResult As Long
'Invoke tapiRequestMakeCall. If tapiRequestMakeCall returns 0, the
'request has been accepted. It is up to the call manager application
'to do any further work. The second-to-last argument should be
'changed to be the name of the person you are dialing.
nResult = tapiRequestMakeCall&(Trim$(txtNumber), CStr(Caption), "Test Dial", "")
'Display message if error
If nResult <> 0 Then
buff = "Error dialing number : "
Select Case nResult
Case TAPIERR_NOREQUESTRECIPIENT
buff = buff & "No Windows Telephony dialing application is running and none could be started."
Case TAPIERR_REQUESTQUEUEFULL
buff = buff & "The queue of pending Windows Telephony dialing requests is full."
Case TAPIERR_INVALDESTADDRESS
buff = buff & "The phone number is not valid."
Case Else
buff = buff & "Unknown error."
End Select
MsgBox buff
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub EnableDial()
cmdDial.Enabled = Len(Trim$(txtNumber)) > 0
End Sub