[Solved] Save file dialog

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
dstockman12
Posts: 39
Joined: Thu Dec 13, 2007 6:32 pm

[Solved] Save file dialog

Post by dstockman12 »

Greetings:

I need to open a dialog that allows a user to select a directory and name a new (or existing) file to save. This is a typical Save or Save As dialog box in Windows. I have found FilePicker, but this appears to only be for opening a file. What is the corresponding Save/Save As dialog box called? Thanks in advance.

Doug
Last edited by Hagar Delest on Thu Jan 28, 2010 7:17 pm, edited 1 time in total.
Reason: tagged [Solved].
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Save file dialog

Post by Villeroy »

It's the same service which supports 11 "templates" for loading and saving plus optional extra controls:
11 constants specify the type of file-open or file-save:
http://api.openoffice.org/docs/common/r ... ption.html
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
dstockman12
Posts: 39
Joined: Thu Dec 13, 2007 6:32 pm

Re: Save file dialog

Post by dstockman12 »

Villeroy:

Thanks! I got it working, although I am not sure my methods are fully sound. It took me a while to figure out how to set the constants. Did I do it correctly? Do I need the ConvertToURL in here?

Code: Select all

' ******* FilePicker Save File ******************************************
Function FilePickSave As String
Dim FilePicker As Object
Dim FPtype(0) As Integer

FilePicker = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
FPtype(0)=com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE
FilePicker.initialize(FPtype())

If FilePicker.execute() Then
	FilePickSave = ConvertToURL(FilePicker.Files(0))
'	msgbox FilePickSave
EndIf

End Function
Thanks again. If this is correct, I will place [SOLVED] in the title.

Doug
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Save file dialog

Post by Villeroy »

It looks right and it works.
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
User avatar
MikeytheMagnificent
Posts: 137
Joined: Fri Apr 11, 2008 12:06 am
Location: W. Yorks UK

Re: [Solved] Save file dialog

Post by MikeytheMagnificent »

Yep :)

If it looks like a dog and it barks like a dog, it's always worth a sporting bet that it might not be a croc'

:super:

You have to make allowance for Villeroy, too long in the Fatherland, don't you know!
Give him credit though, he's lightening fast out of the traps,
appreciated and faithful servant of the forums.
Many opportunities to add short Tutorials or faq's are missed

1. Must have obvious title to be found easily
2. Keep to objectives
3. Use very clear language
4. Difficult to get right
5. Rewards are few
Post Reply