I have a button in a .ODS spreadsheet with a python macro that modifies some cells.
I need to save this modified .ODS file in another directory and under another name via python.
how to do this?
[Calc] Python macro: Save as
[Calc] Python macro: Save as
OpenOffice 4.1.6
Re: python macro - save as ? Calc
Here is a minimal example of doing a Save As in Python.
Code: Select all
def SaveAs():
oDoc = XSCRIPTCONTEXT.getDocument()
NewURL = "file:///home/fjcc/NewName.ods"
oDoc.storeToURL(NewURL,())
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 34
- Joined: Sun Mar 01, 2015 3:34 am
Re: python macro - save as ? Calc
Please note this was cross posted and also answered here:
https://ask.libreoffice.org/en/question ... e-as-calc/
https://ask.libreoffice.org/en/question ... e-as-calc/
LibreOffice 7.0.2.2
OpenOffice 4.0.1
Ubuntu Mate 20.04.1
Mint 20.3
OpenOffice 4.0.1
Ubuntu Mate 20.04.1
Mint 20.3
Re: python macro - save as ? Calc
FJCC wrote:Here is a minimal example of doing a Save As in Python.
And to save the current file, how do I do?
I tried like this:
Code: Select all
def SaveALL():
oDoc = XSCRIPTCONTEXT.getDocument()
originalFile= oDoc.URL
oDoc.storeToURL(originalFile,())
NewURL = "file:///home/fjcc/NewName.ods"
oDoc.storeToURL(NewURL,())
If I apply this macro above, it saves the current file, but libreoffice calc doesn't understand that the file has been saved and the icon is still red and when closing the document manually displays a dialog asking to save or discard changes.
What is the correct way to save the current file in python?
OpenOffice 4.1.6
Re: python macro - save as ? Calc
http://www.openoffice.org/api/docs/comm ... iable.html
http://www.openoffice.org/api/docs/comm ... able2.html
[Tutorial] Introduction into object inspection with MRI
http://www.openoffice.org/api/docs/comm ... able2.html
[Tutorial] Introduction into object inspection with MRI
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice