It seems that the default directory must be the same for all Libre Office applications. Is it possible to have a different default directory for Calc than for Writer, for example?
Besides an issue where recently the last used folder was the prefefined one when you go to SaveAs/Export (fixed for next version) you can work with as many folders you like.
.
If you open a file from one folder, this should be the folder you see for SaveAs/Export .
As you have not told your version, maybe start here:
You can write your own macro for this task. You can get the main “Documents” folder, and depending on the application type (Calc, Writer and others) you can store the new documents (that has not URL yet) into the desired subfolder. You can control the Dialog boxes of the LibreOffice to set the relevant default folder when it is appeared to enter the file name.
Here is a macro-skeleton for this task:
sub MySpecialSave
dim oDoc, oDocFrame, ps as object
dim sMainPath, sAppName, sFilterName, sFileExtensions, sInitDir, sFileURL as string
Dim FPtype(0) As Integer
Dim oPicker, oFileSystem, oDispatcher as object
dim args1(1) as new com.sun.star.beans.PropertyValue
oDoc = Thiscomponent
'loadxray
'xray oDoc
ps = CreateUnoService("com.sun.star.util.PathSettings")
sMainPath = ps.Work & "/"
'print sMainPath
oPicker = CreateUnoService("com.sun.star.ui.dialogs.OfficeFilePicker")
If oDoc.SupportsService ("com.sun.star.sheet.SpreadsheetDocument") Then
sAppName = "Calc"
sFilterName = "calc8"
sFileExtensions = "*.ods"
oPicker.appendFilter(sFilterName, sFileExtensions)
sFilterName = "calc8_template"
sFileExtensions = "*.ots"
oPicker.appendFilter(sFilterName, sFileExtensions)
end if
If oDoc.SupportsService ("com.sun.star.text.TextDocument") Then
sAppName = "Writer"
sFilterName = "writer8"
sFileExtensions = "*.odt"
oPicker.appendFilter(sFilterName, sFileExtensions)
sFilterName = "writer8_template"
sFileExtensions = "*.ott"
oPicker.appendFilter(sFilterName, sFileExtensions)
end if
If oDoc.SupportsService ("com.sun.star.drawing.DrawingDocument") Then
sAppName = "Draw"
sFilterName = "draw8"
sFileExtensions = "*.odg"
oPicker.appendFilter(sFilterName, sFileExtensions)
sFilterName = "draw8_template"
sFileExtensions = "*.otg"
oPicker.appendFilter(sFilterName, sFileExtensions)
end if
If oDoc.SupportsService ("com.sun.star.presentation.PresentationDocument") Then
sAppName = "Impress"
sFilterName = "impress8"
sFileExtensions = "*.odp"
oPicker.appendFilter(sFilterName, sFileExtensions)
sFilterName = "impress8_template"
sFileExtensions = "*.otp"
oPicker.appendFilter(sFilterName, sFileExtensions)
end if
If oDoc.SupportsService ("com.sun.star.formula.FormulaProperties") Then
sAppName = "Math"
sFilterName = "math8"
sFileExtensions = "*.odf"
oPicker.appendFilter(sFilterName, sFileExtensions)
end if
'https://help.libreoffice.org/latest/he/text/shared/guide/convertfilters.html
'print sAppName
sInitDir = ConvertToURL(sMainPath + sAppName)
oFileSystem = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
If NOT oFileSystem.exists(sInitDir) Then
oFileSystem.CreateFolder(sInitDir)
Wait 300
end if
oPicker.setTitle("MySpecialSaveDialog")
oPicker.setDisplayDirectory(sInitDir)
FPtype(0)=com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS
'https://api.libreoffice.org/docs/idl/ref/TemplateDescription_8idl.html
oPicker.initialize(FPtype())
'xray oPicker
If oPicker.execute() Then
sFileURL = ConvertToURL(oPicker.Files(0))
Print sFileURL
Dim aSaveProperties(1) As New com.sun.star.beans.PropertyValue
aSaveProperties(0).Name = "FilterName"
aSaveProperties(0).Value = sFilterName
aSaveProperties(1).Name = "Overwrite"
aSaveProperties(1).Value = True
oDoc.storeAsURL(sFileURL, aSaveProperties())
EndIf
end sub
Thank you.