Page 1 of 1

Open URL from OpenOffice macro

Posted: Thu Sep 18, 2014 6:56 pm
by aghoras
Hello All,
I'm trying to create a button that, when pressed, will launch a URL in the system's (windows 7) default browser. What is the right way to do this?

Thanks

Re: Open URL from OpenOffice macro

Posted: Fri Sep 19, 2014 2:00 am
by FJCC
I drew a button in a Calc document, right clicked on it and selected Control. In the dialog that appeared, on the General tab, there is a category Action. From that drop down list I selected Open Document/URL. The next category is called URL, where you can type in or browse for the desired URL. After taking the button out of design mode, clicking on it brought up the URL in my default browser.

Re: Open URL from OpenOffice macro

Posted: Sat Sep 20, 2014 3:53 pm
by Nocton
To add to FJCC's repy, it can also be helpful to have the URL in a table so that it can be changed easily either directly in the table or by entry into a text box on a form. In the latter case the code below works well.

Code: Select all

Function openurl(oEv as object)
' to open URL in browser
Dim oForm,oTextBox
oForm=oEv.source.model.parent ' get control's form
oTextBox=oForm.getbyname("txtWebSite")
oEv.source.model.targeturl=oTextBox.text
openurl=true 
End Function
Set the function to the button's 'Approve action' event.

Regards,

Nocton

Re: Open URL from OpenOffice macro

Posted: Sat Sep 20, 2014 9:11 pm
by Villeroy
Slightly different approach in Python with one or many buttons automatically disabled/enabled when changing the record: viewtopic.php?f=13&t=71893&p=323909#p323909