LibreOffice Get URL From Hyperlink

So I like using spreadsheets to mash data with, using the formulas there allow me to generate repetitive tasks easily.  This time I needed to map some Ids together, but they were in the URL of hyperlinks.  So I created the following macro to retrieve the URL from the hyperlink object in libreoffice.

REM s = sheet, c = column, r = row
Function GETURI(s,c,r)
dim doc as object
dim sheet as object
dim mycell as object

doc = ThisComponent
sheet = doc.Sheets(s)
mycell = sheet.getCellByPosition(c,r)

if mycell.Textfields.Count >= 1 then
     GETURI = mycell.getTextfields.getByIndex(0).URL
else
     GETURI = mycell.Textfields.Count
endif

End Function
Go back to top