Ask Your Question

Is it possible to launch a program from a link in a document?

asked 2017-04-30 02:48:30 +0200

unholymachine gravatar image

updated 2020-10-02 17:27:18 +0200

Alex Kemp gravatar image


I'm trying to launch a program from a link in a document. I've tried clicking the add url button, selecting document (not URL) then typing out the full path to the piece of software but when I click the link it opens in my distribution's default text editor. I'd like to launch Chrome, which is installed but NOT the default selected browser for the system from a link in a document. Is this even possible? If so how would I go about doing it?


edit retag flag offensive close merge delete


Hello unholymachine, you could do this with a macro calling the Shell() function. The precise command depends on your Operating System:

on Unix it would be Shell( "chromium-browser " + yourURL )

on Windows it would be Shell( "chrome:\\newtab " + yourURL ) ( not tested)

librebel gravatar imagelibrebel ( 2017-04-30 04:01:54 +0200 )edit

I still get an error of:

"shell(%2522google-chrome-stable%2522)" is not an absolute URL that can be passed to an external application to open it.

With or without the addition of a '+' and a valid url.

Btw, this is all under linux on LibreOffice

unholymachine gravatar imageunholymachine ( 2017-04-30 15:31:05 +0200 )edit

try to run this macro, does it give an error?

Sub Test
    Dim strURL As String
    strURL = ""
    Shell( "google-chrome " + strURL )
End Sub
librebel gravatar imagelibrebel ( 2017-04-30 16:24:47 +0200 )edit

I'll confirm @librebel answer:

Shell "google-chrome-stable"

Set FireFox as default for test. Opened link in Chrome. Also reversed test with Chrome & used firefox and no problem. This on Mint 18 system with LO v5.3.2.2 (have done similar with other LO versions - even back to v4.x).

Ratslinger gravatar imageRatslinger ( 2017-05-01 04:06:50 +0200 )edit

On Linux clicking on a hyperlink runs /usr/bin/x-www-browser with the link target as the first argument. One can edit this script to handle various file types as desired. For example, to open PDF files with kpdf and everything else with chrome one could use:


if [[ $1 == *".pdf" ]] 
    kpdf "$@"
    /opt/google/chrome/chrome "$@"
akh gravatar imageakh ( 2020-10-28 06:04:30 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2017-04-30 15:35:56 +0200

EasyTrieve gravatar image

updated 2017-04-30 16:46:30 +0200

In linux it opens executables like *.sh files in a text editor, photos in a photo viewer, archives like *.zip in an archive manager, music files in a music box app, but I couldn't get it to execute anything directly.

But under Further Settings you can select Form: Button. This creates a button, then toggle design mode and select the button and open the properties and edit the Events. Add an event for Mouse button pressed which calls something like this basic code:

Sub Main
    Shell("/usr/bin/google-chrome-stable %U")
End Sub

You may have to adjust the URL to fit w/ your system.

edit flag offensive delete link more


I'm glad I bothered testing before saying: using /usr/bin/env google-chrome-stable %U doesn't work, it just doesn't execute Chrome although the LED indicates else.

rautamiekka gravatar imagerautamiekka ( 2017-05-05 17:25:08 +0200 )edit

;-), Works for me. But I did say,: "You may have to adjust the URL to fit w/ your system." Also you might want to adjust any suffix. The "%U" is for my Debian Linux Cinnamon OS. I expect this will be heavily OS dependent.

EasyTrieve gravatar imageEasyTrieve ( 2017-05-05 18:12:26 +0200 )edit

answered 2017-04-30 12:14:13 +0200

Lupp gravatar image

updated 2017-04-30 12:14:53 +0200

At least on Win you can do that without writing user code by assigning a hyperlink to a textportion giving the executable as 'Internt Path:' in the file:/// notation. Example:
file:///C:/Program Files (x86)/Maxima/wxMaxima/wxmaxima.exe
which works on my computer. You may include parameters.

Well, the executable is not actually "in the internet", but it surely is not found in the document.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-04-30 02:48:30 +0200

Seen: 2,613 times

Last updated: Apr 30 '17