How to pass path in ubuntu?

I see examples describing when passing a path will write like this (use \ instead of /):

systemFile$ = "c:\folder\mytext.txt"
url$ = ConvertToURL( systemFile$ )

And i have a file with the path it is: /var/www/storage/123456789.xlsx) then how would i have to declare the systemFile$ variable.
Or i have a macro, it accepts a path, when i call that macro i have to pass that path like?
P/s: i am using ubuntu

Simply try out what happens when you replace the “c:\ …” with “/var/…”

I tried but it seems to be faulty

Works for me.

with my path will look like this ?
\var\www\storage\123456789.xlsx ?

You need URL ‘/’ format instead of the Windows like Path (backslash) in the macros if you want a highetr compatibility.
You can get the “paths” of some important folders from the office suite by using API.
On Windows the Documents folder:

Function GetBackupPath() as string
Dim ps As Object
	ps = CreateUnoService("")
GetBackupPath = ps.Backup
End Function

Function GetDocumentsPath() as string
Dim ps As Object
	ps = CreateUnoService("")
GetDocumentsPath = ps.Work & "/"
End Function

Backslash is the Windows path separator. Real operating systems use the slash.

i am using ubuntu 20.

I think that LO API function works on every supported Op. Sys.

I observed that container apps (flatpak etc.) can not see the entire directory tree. For instance, some app can not save to /tmp because the app reports that /tmp does not exist.

A “system file name” mentioned in the documentation (better “system file path”) is a system-specifc string, that is used on current operating system for file paths.

So the example there, using "c:\folder\mytext.txt", is for Windows; any other OS would use its respective string; in your case, you would use

systemFile$ = "/var/www/storage/123456789.xlsx"
url$ = ConvertToURL( systemFile$ )

You didn’t show us what specifically did you try that was faulty, and “faulty” meaning what exact result; but from

one may assume that you modified your system file path is some odd way, to use Windows separators, which indeed would fail on Linux.

Thank you, I have already used the correct link.
Currently I have a macro like this and this is the error I get when I run it:


        Dim document As Object
        Dim pageStyles As Object
        Dim Url As String

        Url = ConvertToURL("/var/www/storage/app/public/cvs/123456789.xlsx")

        Dim loadComponentProperties(1) As New
        loadComponentProperties(0).Name= "FilterName"
        loadComponentProperties(0).Value= "Calc MS Excel 2007 XML"
        loadComponentProperties(1).Name= "Hidden"
        loadComponentProperties(1).Value= True

        document = StarDesktop.loadComponentFromURL(Url, '_blank', 0, loadComponentProperties());

error return:

An exception occurred


Message: expected 4 arguments, got 1.

Is not a string in StarBasic delimited by double quotes rather than single quotes? The single quote is used to precede a comment.

Ok, after fixing it and it crashes at runtime.
Do you know what causes that?

I tried to open your file, and I saw no crashes.

Now it is no longer hanging but an error has been returned: Object variable not set.

document = StarDesktop.loadComponentFromURL(Url, "_blank", 0, loadComponentProperties)

cannot be assigned to document variable

Works fine.

1 Like
IsNull(StarDesktop.loadComponentFromURL(Url, "_blank", 0, loadComponentProperties()))

return true;
I checked the Url with the FileExists function and it returned true

Method loadComponentFromURL

returns NULL if it failed

There can be several reasons if you cannot open an existing file. Try opening the file through the user interface.

yes, i have tried it successfully.
On the user interface my macro was working fine, but in headless mode it didn’t work.