This macro worked on my previous laptop. It is modified from here (the second OSM code: https://digital-geography.com/geocoding-addresses-directly-in-libreoffice-calc/ - my version previously worked under
Function GetGeoDataOSM(sSearch as String) as String
If Len(sSearch) = 0 Then Exit Function
URL = "http://nominatim.openstreetmap.org/search?format=xml&q="
URL = URL & sSearch
oSimpleFileAccess = createUnoService( "com.sun.star.ucb.SimpleFileAccess" )
On Error GoTo ErrorResponse
oInputStream = oSimpleFileAccess.openFileRead(URL)
oTextStream = createUnoService("com.sun.star.io.TextInputStream")
oTextStream.InputStream = oInputStream
aDelimiters = Array(ASC(">"),ASC("<"),ASC(" "),ASC("="))
sLastString = ""
Do While NOT oTextStream.isEOF
sThisString = oTextStream.readString(aDelimiters,True)
Select Case sLastString
Case "lat":
sLat = sThisString
Case "lon":
sLon = sThisString
End Select
sLastString = sThisString
Loop
GetGeoDataOSM = " Longitude: " & sLon & " Latitude: " &sLat
oInputStream.closeInput()
Exit Function
ErrorResponse:
GetGeoDataOSM = "no values found!!!"
End Function
When I use it in a cell (e.g. =getgeodataosm(D63), I get #name
WHen I run it in the macro editor, I get a Basic runtime error on the second line "argument is not optional'. If I delete that line and step through the macro, I get the same error on the next line.
Anyone got any ideas? I'm on LO 24.2.7.2 - it previously worked in LO 5.