I’m trying to use the following code to save a file as a calc file (extension “.ods”). It uses a sub to save it (save File sub) but it does as a Write file no matter the properties set in the dialog box. I know how to do it without a dialog, but I need it. All attempts failed, so I’m asking for help.
sub SalvaComBox
Dim FPType(0) as integer
FPType(0) = 10
oFilePicker = CreateUnoService("com.sun.star.ui.dialogs.OfficeFilePicker")
oFilePicker.appendFilter("Planilha ODF (*.ods)","*.ods")
oFilePicker.DisplayDirectory = ConvertToURL("C:\Users\mydocs\Desktop\")
oFilePicker.setTitle ("Save file as:")
oFilePicker.initialize(FPType())
oFilePicker.execute
if ubound(oFilePicker.Files) < 0 then
sFileName =""
else
sFileName=oFilePicker.Files(0)
end if
sFilterName=oFilePicker.CurrentFilter
if sFileName <> "" then
call saveFile(sFilename)
MsgBox "file saved"
end if
end sub
sub saveFile(sfileName as string)
oSimpleFileAccess = createUNOService ("com.sun.star.ucb.SimpleFileAccess")
oOutputStream = createUNOService ("com.sun.star.io.TextOutputStream")
oOutputStream.setOutputStream(oSimpleFileAccess.openFileWrite(sFileName))
end sub