Coding For API

abbaddon223

Registered User.
Local time
Today, 07:13
Joined
Mar 13, 2010
Messages
162
[FONT=&quot]Hi,[/FONT]

[FONT=&quot][/FONT]
[FONT=&quot]I'm hoping there's an expert out there.....
[/FONT]


[FONT=&quot]I have some VBA coding that is allowing me to place a VOIP call via a SIP provider. All works fine. What I'm looking for is an extra bit that can cancel the call when prompted (command button macro say).[/FONT]

[FONT=&quot][/FONT]
[FONT=&quot]The coding is below - thanks in advance for any help. Sincerely yours: stuck.
[/FONT]
[FONT=&quot]
[/FONT]
[FONT=&quot]Private Sub Command87_Click()[/FONT]
[FONT=&quot] Dim ie As New InternetExplorer[/FONT]
[FONT=&quot] Dim htmldoc As HTMLDocument[/FONT]
[FONT=&quot] Dim number As String[/FONT]
[FONT=&quot] Dim res As String[/FONT]
[FONT=&quot] Dim contact_name As String[/FONT]
[FONT=&quot] Dim agent As String[/FONT]
[FONT=&quot] Dim extension As String[/FONT]
[FONT=&quot] Dim url As String[/FONT]
[FONT=&quot] Dim acct, pass As String[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] agent = Form_Frm_User_Select.Combo_UserSelect.Value[/FONT]
[FONT=&quot] Select Case agent[/FONT]
[FONT=&quot] Case "Name"[/FONT]
[FONT=&quot] extension = "001"[/FONT]
[FONT=&quot] acct = "Business001"[/FONT]
[FONT=&quot] pass = "Password"[/FONT]
[FONT=&quot] [/FONT]

[FONT=&quot][/FONT][FONT=&quot] End Select[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] number = Replace(Me.ContactNumber, " ", "")[/FONT]
[FONT=&quot] number = Replace(number, "-", "")[/FONT]
[FONT=&quot] contact_name = Me.ContactName[/FONT]
[FONT=&quot] url = "http://contact-pro6.co.uk/callapi/251/Call/MakeCall?" + _[/FONT]
[FONT=&quot] "Account=" & acct & _[/FONT]
[FONT=&quot] "&PassPlain=" & pass & _[/FONT]
[FONT=&quot] "&ExtensionAccount=0367*" + extension + _[/FONT]
[FONT=&quot] "&FromNumber[]=0367*" + extension + _[/FONT]
[FONT=&quot] "&PhoneNumberToCall=" + number + _[/FONT]
[FONT=&quot] "&CallerIDName=" + contact_name + _[/FONT]
[FONT=&quot] "&CallerIDNumber=" + number[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] ie.Visible = False[/FONT]
[FONT=&quot] ie.navigate url[/FONT]
[FONT=&quot] Do[/FONT]
[FONT=&quot] DoEvents[/FONT]
[FONT=&quot] Loop Until ie.readyState = READYSTATE_COMPLETE[/FONT]
[FONT=&quot] Set htmldoc = ie.Document[/FONT]
[FONT=&quot] 'do some debug with the result in the HTMLDoc.[/FONT]
[FONT=&quot] 'res = htmldoc.documentElement.innerHTML[/FONT]
[FONT=&quot] 'Debug.Print (res)[/FONT]
[FONT=&quot] ie.Quit[/FONT]
[FONT=&quot] [CallStart].Value = Time()[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]End Sub[/FONT]
 
I'm not sure but if I understand what's going on there, quiting ie will hang up. So, I think you'd have to put a private boolean variable at the module level say:

Private HangUp As Boolean

Set that to false at the start of the call

Change

Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE

to

Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE Or HangUp = True

and on the click event of the Hang Up button set HangUp to true.
 
Hi there,

That you very much for the advice. That was bang on!!!!! :D
 
Good to hear. That's a funky bit of functionality your database has there ;)
 

Users who are viewing this thread

Back
Top Bottom