The following is an example subroutine which constructs the necessary JSON class from variables and demonstrates how to call the SendSms function.
Send SMS Message
The following method can be called from an ActiveX button accessed through Excel 2013 developer tools. It is essential the encompassing VBAProject references “Microsoft winHTTP Services” otherwise an “invalid user defined type” error message will be presented.
Sub SendSms() Const vbq As String = """" Dim URL As String Dim user As String Dim pass As String Dim source As String Dim destination As String Dim sms As String URL = "http://api.123-txt.com/rest/SendSms" user = "user@email.goes.here pass = "user_password_goes_here" source = "virtual_number " destination = "recipient_mobile " sms = "SMS_to_send_goes_here" Dim jsonRequest As String jsonRequest = jsonRequest & "{" jsonRequest = jsonRequest & vbq & "user" & vbq & ":" & vbq & user & vbq & "," jsonRequest = jsonRequest & vbq & "pass" & vbq & ":" & vbq & pass & vbq & "," jsonRequest = jsonRequest & vbq & "source" & vbq & ":" & vbq & source & vbq & "," jsonRequest = jsonRequest & vbq & "destination" & vbq & ":" & vbq & destination & vbq & "," jsonRequest = jsonRequest & vbq & "sms" & vbq & ":" & vbq & sms & vbq jsonRequest = jsonRequest & "}" Dim objHTTP As New WinHttp.WinHttpRequest objHTTP.Open "POST", URL, False objHTTP.setRequestHeader "Content-Type", "application/json" objHTTP.send (jsonRequest) 'Debug.Print objHTTP.Status ' Optional to see the returned Status. 'Debug.Print objHTTP.ResponseText ' Optional to see the returned response text. End Sub