Adding the dialer function to telephone numbers on excel 2000

  • Thread starter Thread starter Ellen Caravello
  • Start date Start date
E

Ellen Caravello

I want to use an excel spreadsheet to collect data which
includes a telephone number...and I want to be able to
click on the telephone number and dial out - similar to
ACCESS' capabilities, but I want to use Excel 2000.

Thanks for your help..
 
Hi Ellen,

Create a module and insert the code below. Suppose you have names on sheet
column 1 and phones numbers on column 2, select one row and run the Dialer.

Declare Function tapiRequestMakeCall Lib "tapi32.dll" _
(ByVal stNumber As String, ByVal stDummy1 As String, _
ByVal stDummy2 As String, ByVal stDummy3 As String) As Long
Public Const ID_CANCEL = 2
Public Const MB_OKCANCEL = 1
Public Const MB_ICONSTOP = 16, MB_ICONINFORMATION = 64

Sub Dialer()
ColName = 1
ColPhone = 2
vRow = Selection.Row - 1
If vRow = 0 Then Exit Sub
DialNumber Range("A1").Offset(vRow, ColPhone - 1).Value,
Range("A1").Offset(vRow, ColName - 1).Value
End Sub


' ***********************************************************
' FUNCTION: DialNumber()
'
' PURPOSE: To dial a telephone number using the computer's modem
'
' ARGUMENTS:
' PhoneNumber: The telephone number to dial
'
' EXAMPLE:
' Type the following in the Debug window to dial a phone number:
'
' ? DialNumber("555-1212")
'
' About this code see Microsoft knowledgebase article Q141625
' ***********************************************************
Function DialNumber(PhoneNumber, Optional vName As Variant)
Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String
Dim RetVal As Long
' Ask the user to pick up the phone.
Msg = "Please pickup the phone and click OK to dial " _
& Chr(13) & Chr(13) & PhoneNumber & " " & vName
MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
MsgBoxTitle = "Dial Number"
If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
Exit Function
End If
' Send the telephone number to the modem.
RetVal = tapiRequestMakeCall(PhoneNumber, "", vName, "")
If RetVal < 0 Then
Msg = "Unable to dial number " & PhoneNumber
GoTo Err_DialNumber
End If
Exit Function
Err_DialNumber: 'This is not an On Error routine.
Msg = Msg & Chr(13) & Chr(13) & _
"Make sure no other devices are using the Com port"
MsgBoxType = MB_ICONSTOP
MsgBoxTitle = "Dial Number Error"
MsgBox Msg, MsgBoxType, MsgBoxTitle
End Function


HTH
 
Back
Top