It is also possible to open the source file as template → it will create a copy of source file, and then save this new file to ODS via storeAsUrl. The example is with FilePicker, there are the filters for ODS and CSV in function chooseFile, you can change it.
Sub openConvertSave 'open template and save it as ODS
dim oDoc as object, sFileName$, sTemplateUrl$
rem open file as template
'sTemplateUrl="d:\template.ods" 'your constant source file
sTemplateUrl=chooseFile("d:\mydoc") 'File Picker in initial directory
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name="AsTemplate"
args1(0).Value=true 'new file from Template
oDoc=StarDesktop.loadComponentFromURL( ConvertToUrl(sTemplateUrl), "_blank", 0, args1() ) 'open the copy of file
'sFileName=ConvertToUrl("C:\path\to\my\folder\") & Format(Now, "dd-mm-yyyy") & ".ods"
sFileName=ConvertToUrl("d:\") & Format(Now, "dd-mm-yyyy") & ".ods" 'output file
dim dummy(0) as new com.sun.star.beans.PropertyValue
dummy(0).Name="FilterName"
dummy(0).Value="calc8"
oDoc.storeAsURL(sFileName, dummy)
End Sub
Function chooseFile(optional sInitDir$) as string 'dialog for FilePicker opened in initial directory
dim oFileDlg as object, oFileAccess as object, oFiles as object, sFile$, bDir as boolean
rem check init directory
if NOT isMissing(sInitDir) then 'parameter sInitDir exists
if FileExists(sInitDir) then bDir=true 'directory exists
end if
if bDir=False then sInitDir=CreateUnoService("com.sun.star.util.PathSettings").Work 'initial directory from menu: Tools/Options -> LibreOffice/Paths -> My Documents
oFileDlg=CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
with oFileDlg 'set the filter for shown files in filepicker
.AppendFilter("All files (*.*)", "*.*")
.AppendFilter("Calc (*.ods)", "*.ods")
.AppendFilter("CSV (*.csv)", "*.csv")
.SetCurrentFilter("Calc (*.ods)") 'default filter in dialog
end with
oFileAccess=CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
oFileDlg.SetDisplayDirectory( ConvertToUrl( sInitDir ) )
if oFileDlg.execute() then 'file picker dialog
oFiles=oFileDlg.getFiles()
if ubound(oFiles)>=0 then
sFile=oFiles(0)
end if
end if
if sFile="" then stop 'no file selected
chooseFile=sFile
End Function