Ask Your Question

Libreoffice base - How to open a file without an absolute hyperlink?

asked 2020-04-03 05:58:41 +0100

MadCloud101 gravatar image

updated 2020-08-06 13:26:36 +0100

Alex Kemp gravatar image

I have come across a method to open an internal form using a macro with ThisDatabaseDocument.FormDocuments, however, I want to open a calc file in the same folder as the database, and regardless of what folder that is, so the database can be moved or opened on other computers and still work. How can I refer to the folder the database is in to link files from it?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-04-03 06:47:09 +0100

Ratslinger gravatar image

updated 2020-04-03 07:03:53 +0100


Here is one tested method:

Option Explicit
Sub getPath
    Dim sCalcFile As String
    Dim sAbsolutePath As String
    sCalcFile = "YOUR_CALC_FILE_NAME.ods"
    If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
    End If
    sAbsolutePath = DirectoryNameoutofPath(ThisComponent.Parent.getURL(), "/") & "/" & sCalcFile
Rem Can open on Linux Ubuntu with
    Shell ("bash -c 'soffice " & sAbsolutePath & "'")
End Sub


You can also move the resulting path to a Button set with Action = Open document/web page. Code for that can be found on this post -> How can a value be passed to URL in LO Base Form

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-04-03 05:58:41 +0100

Seen: 137 times

Last updated: Apr 03 '20