Ask Your Question

In base how to open a URL field?

asked 2018-06-14 00:30:10 +0200

EasyTrieve gravatar image

updated 2018-06-15 19:48:44 +0200

If a text field holds a URL string, how can one easily open the link in your browser?

(A similar question is here:

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2018-06-14 00:41:46 +0200

EasyTrieve gravatar image

updated 2018-06-15 19:40:24 +0200

Use this method to just hit F9 on the URL to easily open the web page. (I had seen the method for an extra button, but I didn't want another button for this).

Set this as the KeyPressed event for the field:

' --- If F9 key hit then execute the URL (i.e. show the file or web page) -------------'
Sub KeyPressedEvent(oEvent As Object)
  If oEvent.KeyCode = Then   'Adjust to suit your taste'

    'Read the text from the file selection (Assuming the field is named 'URL')'
    s = oEvent.Source.Model.Parent.GetByName("URL").Text
    s = convertToUrl(s) 

    'Start the file with the appropriate URL connection'
    DIM oShell  AS OBJECT  
    oShell = createUnoService("")

  End If
End Sub

Tip: So when the user hovers over the URL field heading they get a tool tip also set the Help text property on the URL Control to something like: 'Hit F9 to open URL in your browser or other appropriate tool'.

edit flag offensive delete link more

answered 2018-06-14 00:57:48 +0200

Ratslinger gravatar image


I find using a button to be quite effective. With this macro:

Sub GetURL
    oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
    DocCtl = ThisComponent.getCurrentController()
    oField = oForm.getByName("txtURL")
    oButton = oForm.getByName("Push Button 1")
    CtlView = DocCtl.GetControl(oField)
    oButton.TargetUrl = CtlView.Text
end sub

attached to After record change event of form and on the push button property Action set to Open document/web page you only need a click of the button to open the link. Works well for opening other documents as well.

No need to use Shell.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-06-14 00:30:10 +0200

Seen: 71 times

Last updated: Jun 15