VBA to dial a phone number through a connected modem

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello All,
This idea just came to me and I wanna verify if it holds. I wanna dial a phone line through a connected modem by a VBA code. If this is possible please let me know.
Thanks
Kelly
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Wow, that's an oldie.

Code:
Option Explicit

' from http://support.microsoft.com/kb/141625

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


' ***********************************************************
' 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")
' ***********************************************************
Function DialNumber(PhoneNumber)
  Dim Msg As String
  Dim MsgBoxType As Integer
  Dim 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 " _
        & PhoneNumber
  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, "", "", "")

  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 & vbCr & vbCr & _
        "Make sure no other devices are using the Com port"
  MsgBoxType = MB_ICONSTOP
  MsgBoxTitle = "Dial Number Error"
  MsgBox Msg, MsgBoxType, MsgBoxTitle
End Function
 
Upvote 0
Hello shg,
I have a compile error from the below and I am asked to update it for 64 bit use.
Code:
Declare Function tapiRequestMakeCall Lib "tapi32.dll" _
                                     (ByVal stNumber As String, ByVal stDummy1 As String, _
                                      ByVal stDummy2 As String, ByVal stDummy3 As String) As Long
 
Upvote 0
The dialer shows but when I dial it just hangs up. Says I should lift the receiver and click to talk then shows "call failed: there was no answer"
 
Upvote 0
I've not used it since I last had a modem, which was two computers ago, so no suggestion, sorry.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top