Open URL from OpenOffice macro

Creating and using forms
Post Reply
aghoras
Posts: 1
Joined: Thu Sep 18, 2014 6:51 pm

Open URL from OpenOffice macro

Post 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
Windows 7. OpenOffice 4.1.1
FJCC
Moderator
Posts: 9563
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Open URL from OpenOffice macro

Post 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.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Nocton
Volunteer
Posts: 533
Joined: Fri Nov 05, 2010 10:27 am
Location: UK

Re: Open URL from OpenOffice macro

Post 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
OpenOffice 4.1.12 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31348
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Open URL from OpenOffice macro

Post 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
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply