In the event someone else is looking for how to do this a fellow ask.Libre member was kind enough to write the following macro for me in reply to this question:
Sub update_target_url()
doc = ThisComponent
form = doc.CurrentController.ActiveSheet.DrawPage.Forms(0)
button = form.getByName("cmd_link")
button.Label = "LibreOffice Ask"
button.TargetURL = "https://ask.libreoffice.org"
End Sub
I edited it to this:
Sub update_target_url()
doc = ThisComponent
selection = doc.CurrentController.selection
form = doc.CurrentController.ActiveSheet.DrawPage.Forms(0)
button = form.getByName("cmd_link")
button.Label = "Go"
button.TargetURL = selection.String
End Sub
Then I recorded a macro of selecting the cell I wanted it to select which in this case was E7 and got this code from the recorded macro I saved:
REM ***** BASIC *****
Sub Main
End Sub
sub selectE7
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$E$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
end sub
I then took the snippet of code that selected the cell from the above generated macro I recorded:
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem Select vLookUp Cell
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$E$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
And added it to the update_target_url macro.
Here is the end result and macro code:
Sub update_target_url()
rem define variables
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$E$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
doc = ThisComponent
activeSheet = doc.CurrentController.ActiveSheet
cellActiveSheetE7 = activeSheet.getCellRangeByName("E7")
nextTargetURL = cellActiveSheetE7.String
selection = doc.CurrentController.selection
form = doc.CurrentController.ActiveSheet.DrawPage.Forms(0)
button = form.getByName("cmd_link")
button.Label = "Go"
button.TargetURL = selection.String
End Sub