Hi, i would like to connect Libre Office CALC to an http API in order to send sms with my Calc sheet. I am a Newbie and a passionate of EXCEL and Calc Sheets and MACROS.
I have a service provider example.com to send this sms through his api via EXCEL.
But I need to do it with CALC and libre Office uses another Basic called OOoBasic and don’t know how are the Methods and objects here.
I attached my VBA code in EXCEL and if someone knows how to connect an API via http, URL, LET ME KNOW PLEASE.
The code that I am interesed is the following:
'**** Conect to the API via Htpp ****************
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0") 'Create Object
oXMLHTTP.Open "GET", RouteHtml
oXMLHTTP.Send
Send_SMS = oXMLHTTP.responseText 'The sms provider give us a feedback to know if all went fine.
'** Clean the object *********
Set oXMLHTTP = Nothing
With EXCEL we conect with a library in EXCEL to create a new object, but with CALC, how do we reference this library?
I would appreciate any help. Thanks a lot. The whole code for EXCEL SPREADSHEET is this:
Function Send_SMS(sMobileNumbers As String)
'Send sms via Excel. For this you will have to activate Reference -> Microsoft XML v6.0 in menu VBA Tools/References/ (Activate library VBA Microsoft XML v6.0)
'You can send sms with excel. Send one o several sms. If you want to send same text to several telephones numbers, you must separate each telephone with a coma.
'For instance: sMobileNumbers = "49123456789,32123456789,34123456789"
'*** Este macro es para Excel ******************
Dim SmsOperator_Provider As String
Dim oXMLHTTP As Object
Dim Result As String
Dim RouteHtml As String
Dim sUrl As String
Dim sAPI_ID As String
Dim sPassword As String
Dim sUsername As String
Dim sTelefonFrom As String
Dim sSenderId As String
Dim Text_Sms As String
Dim sreq_feat As String
'***** Get tHe data from our EXCEL Sheet **************
sTelefonFrom = Worksheets("Sms").Range("B4").Value
Text_Sms = Worksheets("Sms").Range("C4").Value
SmsOperator_Provider = Worksheets("Sms").Range("C2").Value 'NAME from our Sms operator.
sUrl = Worksheets("Sms").Range("B10").Value
sUsername = Worksheets("Sms").Range("B11").Value
sPassword = Worksheets("Sms").Range("B12").Value
sAPI_ID = Worksheets("Sms").Range("B13").Value 'id de registro API en proveedor de sms
sSenderId = Worksheets("Sms").Range("B14").Value 'id del que envia el sms.
sreq_feat = Worksheets("Sms").Range("B15").Value 'Es el requisito que se pone al enlace para que salga el id sender en el sms.
'***** Concatenate the http API pattern '*********
'https://www.smsdiscount.com/myaccount/sendsms.php?username=xxxxxxxxxx&password=xxxxxxxxxx&from=xxxxxxxxxx&to=xxxxxxxxxx&text=xxxxxxxxxx
'For several clients the variable must be like this: sMobileNumbers = "+34123456789,+34123456789,+34123456789"
RouteHtml = sUrl
RouteHtml = RouteHtml & "username=" & sUsername
RouteHtml = RouteHtml & "&password=" & sPassword
RouteHtml = RouteHtml & "&from=" & sTelefonFrom
RouteHtml = RouteHtml & "&to=" & sMobileNumbers
RouteHtml = RouteHtml & "&text=" & Text_Sms
'**** Conect to the API via Htpp ****************
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0") 'Create Object
oXMLHTTP.Open "GET", RouteHtml
oXMLHTTP.Send
'*** Get the feedback from SMS_Provider **************
'Usually they provide some information to know whether sms was send successfully or not.
Send_SMS = oXMLHTTP.responseText 'The sms provider give us a feedback to know if all went fine.
'** Clean the object *********
Set oXMLHTTP = Nothing
End Function