2

I want to write a macro on a LibreOffice spreadsheet, to send an HTTP request to an web URL and receive a JSON like response. Can i do it with LibreOffice basic macro programming? Where can i get information about the API.

I really appreciate any tips.

Thanks

Ryan Leach
  • 4,262
  • 5
  • 34
  • 71

1 Answers1

7

I'm too late to help Antonio, but for posterity...

You can call spreadsheet functions from Basic, as explained in the open office docs. Here's a simple example that invokes the WEBSERVICE() function:

Function GetWebContent(url As string) As String
    On Error GoTo ErrorHandler

    Dim funtionAccess As Object
    functionAccess = createUnoService("com.sun.star.sheet.FunctionAccess")

    GetWebContent = functionAccess.callFunction("WEBSERVICE",Array(url))

    Exit Function
ErrorHandler:
    GetWebContent = "Error " & Err
End Function


Function Test

    Dim url As String
    url = "http://www.google.com"

    Dim response As String
    response = GetWebContent(url)

End Function
mr_plum
  • 2,448
  • 1
  • 18
  • 31
  • I'm getting an IllegalArgumentException when I use an "https" address instead of an "http" address - is that just not allowed?? – Erhannis Mar 21 '21 at 00:07