You will need to add the Microsoft Communications Control to your form - find it in Tools -> Controls -> ActiveX controls.
The following code will need modifiying to suit your application, and can be used in the [color blue].Click()[/color] event of a commandbutton.
It assumes a modem on com port 2, and the reference to the port will need to be changed in the code for a port other than 2.
It also assumes a table containing the phone no, and if you need to dial a number to obtain an outside line, an example of the necessary code is also included.
Once the connection is made, the user has control of the phone line, and the program terminates.
[color blue]
WITH THISFORM.oleControl1
[tab].Enabled = .T.
[tab].sThreshold = 1
[tab].rThreshold = 1
[tab].CommPort = 2
[tab].PortOpen = .T.
[tab]IF EMPTY(USER.prefix)
[tab][tab].output = [ATDT] + ALLTRIM(CONTACTS.phone_no)+CHR(13)
[tab]ELSE
[tab][tab].output = [ATDT] + ALLTRIM(USER.prefix)+[,]+ALLTRIM(CONTACTS.phone_no) + CHR(13)
[tab]ENDIF
[tab]WAIT WINDOW ;
[tab][tab][Please press the handsfree button on the phone] ;
[tab][tab]+ CHR(13) ;
[tab][tab]+ [and then lift the receiver when the bell sounds.] ;
[tab][tab]TIMEOUT 5
[tab]SET BELL TO [sounds\ringin.WAV], 0
[tab]?? CHR(7)
[tab]SET BELL TO
[tab].output = [ATH0Z] + CHR(13)
[tab].sThreshold = 0
[tab].rThreshold = 0
[tab].PortOpen = .F.
[tab].CommPort = 1
[tab].Enabled = .F.
ENDW
[color black]
Happy talking!
![[talk] [talk] [talk]](/data/assets/smilies/talk.gif)