How to solve "invalid parameter" error when saving as .ods Calc file

I occasionally encounter the “invalid parameter” error when saving as .ods Calc file.

Note:

This is albeit the same set of instructions did not previously show the “invalid parameter” error.

LibreOffice Version: 6.3.5.2 (x86)

Operating System: Windows 7 Ultimate Service Pack 1

Dim Prop(1) as New com.sun.star.beans.PropertyValue
Dim saveAsODSArgs(1) as new com.sun.star.beans.PropertyValue

dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

sOutputPath = DirectoryNameoutofPath(ThisComponent.getURL(),"/")
sOutputFileName = "WeeklyCollectionReportWorkbook.ods"

saveAsODSArgs(0).Name = "URL"
saveAsODSArgs(0).Value = sOutputPath & "/" & sOutputFileName
saveAsODSArgs(1).Name = "FilterName"
saveAsODSArgs(1).Value = "writer8"
			
dispatcher.executeDispatch(ThisComponent.CurrentController.Frame, ".uno:SaveAs", "", 0, saveAsODSArgs())

Present Solution

To solve the “invalid parameter” error, I restart LibreOffice Calc.

If the problem persists, I restart the Operating System.

Question:
What is the best technique to solve this problem?

Thank you. Peace.

may be you need “” instead of “/” for windows OS? (proper that you’d mention your OS!)

imho there are! functionalities in LO that let you handle path names in macros OS independent ??? but i’m not familiar with it, just use the search engine of your choice, or search in ‘ask’ or ‘bugs’ …

peace and sanity …

From my understanding, as URL input for the PropertyValue, “saveAsODSArgs”, forward slash, i.e. “/”, is correct regardless of the Operating System. Thank you.

There are API functions ConvertToURL() and ConvertFromURL() for exact converting the Windows style Full Path strings to URL format. Not only the slashes matter, but even some “special characters” will be converted when you use these functions.

OK! Thank you.

Do you want convert a spreadsheet file into textual format? The “.ods” file extension and the “Writer8” export filter are not compatible…

In this case, the output file is “.ods”. What is the correct export filter if not “Writer8”? Thank you.

https://help.libreoffice.org/latest/he/text/shared/guide/convertfilters.html
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=7280

OK! I verified that using “Calc8” as the export filter name successfully saves the output .ods file. I shall continue to observe if the “invalid parameter” error re-occurs using a Windows Machine. Thank you.