I needed a file picker for porting my old VBA-project to LibreOffice Basic environment…and
was about getting really mad…
oFP = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oFP.appendFilter("csv", "*.csv")
if oFP.execute():
file_path = uno.fileUrlToSystemPath(oFP.SelectedFiles[0])
Thanks, I’ve update the comment above!
The aspect of FilePicker and FolderPicker types below depend upon
Tools > Options > LibreOffice > General, Use LibreOffice dialogs
API Dialog Types
File Selection: FilePicker Objects
.
com.sun.star.ui.dialogs.FilePicker
From above configuration.
.
com.sun.star.ui.dialogs.OfficeFilePicker
Forces LibreOffice style.
.
com.sun.star.ui.dialogs.SystemFilePicker
Forces OS style.
.
.
Directory Selection: FolderPicker Objects
.
com.sun.star.ui.dialogs.FolderPicker
From above configuration.
.
com.sun.star.ui.dialogs.OfficeFolderPicker
Forces LibreOffice style.
.
com.sun.star.ui.dialogs.SystemFolderPicker
Forces OS style.
The FilePicker service mentioned above by @karolus is analogous to the Microsoft Office FileDialog object and has no fewer capabilities.
The former also has the advantage of working on real operating systems, and not just on M$ Windows
@everyone
If so, then why there’s LibreOffice for Windows which some thinks is not an operating system at all? A quite known musician and guitarist Ritchie Blackmore stated once:“Art is aimed at minorities, and I’m not an artist, I play guitar in a band…”
Instead of focusing on an unrelated personal opinion, look at the important part of “this form is portable, unlike using Windows-specific constructs”.
@mikeganski
I’m working on Windows which is clearly sated in the title of this topic and by the way the the file picker presented has no requirement for installing of any part of Microsoft Office at all. As for the policy of the “firm” I deeply hate it, but that’s hardly up to the programmers, the major shareholders make the decisions.
I fail to decipher the important (in the frame of the Ask LibreOffice site) part in your words. Please say clearly: do you mean, that you think your way useful, after learning the dedicated easy portable way, and so you dislike thanking people showing you the better (in my opinion) alternative, preferring to focus on some unrelated small piece? OS that you use is unimportant here. But for the wide audience reading the site, the portability aspect is important.
@mikekaganski
I started with LibreOffice and [Star]Basic about a month and a half ago, so it might be that I’m looking for an “easy” way to get things to work when I’m trying to port my old VBA-project to LibreOffice environment.
Oh I see… we need to spoonfeeding @Pertsa with Basic:
oFP = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oFP.appendFilter("csv", "*.csv")
if oFP.execute() then
file_path = convertFromURL(oFP.SelectedFiles(0) )
end if
msgbox filepath
@karolus
What else can I say but I’m grateful… I decided to get my project working in LibreOffice for Windows first and then I could focus on trying to make it platform independent, which I think will be the hardest part.
@mikekaganski
Oh, you don’t have to worry about your position as High Priest even if someone suggests something that doesn’t follow the lines of official policy…