CLI calc open file, execute macro, save and close file

I have a calc document linked with an external cvs file (daily updated).
In it, I have a macro that does a number of processing of this data and saves graphs as image files.
I would like to be able to open this file using localc from the command line, have the macro run, the file be saved and then closed.

So I created a MyMacros.Standard.Module1.SaveAndQuit macro

Sub SaveAndQuit ()
createUnoService (""). executeDispatch (ThisComponent.CurrentController.Frame, ".uno: Save", "", 0, Array ())
ThisComponent.close (true)
End Sub

which is well launched by:

localc --invisible --nofirststartwizard --headless --norestore hopital.ods "macro: ///Standard.Module1.SaveAndQuit"

But the Standard.Graphique.SaveGraphe macro of the hospital.ods document is not launched, although it is associated with the saving of the document.
So I would like the macro MyMacros.Standard.Module1.SaveAndQuit to start the macro
Standard.Graphique.SaveGraphe (Call SaveGraphe) but I can’t.
I go around in circles, not knowing if what I want to do is possible or if it wouldn’t be easier.

I hope that my explanations will be sufficiently clear.

Can someone point me in the right direction please?

Why not call it before the saving procedure from the macro SaveAndQiut?

If these spaces are literally part of the code and call they are wrong.

Like I said, that’s what I tried to do, but I couldn’t. How to call it?

No there is no space. It’s probably a copy/paste problem (I use google translate because of my bad english). In any case, the SaveAndQuit macro alone works.

As far as I know, working with the DispatchHelper object is limited in cases where LibreOffice is started in headless mode. Use methods of UNO objects instead.

Ok thank you but I don’t know how to do it at all. I am a great beginner in macro.

In your case, replace the line

createUnoService (""). executeDispatch (ThisComponent.CurrentController.Frame, ".uno: Save", "", 0, Array ())


1 Like

I have searched so much for this command.
I tested “save” and others, but never the “store”.
It just looks PERFECT, and solves all my problems. Thank you so much.

Good luck!

1 Like

Edited out - please be thoughtful

1 Like

Really sorry.
It is an acronym that we use a lot in French without it having the same violence as the real meaning in English. I didn’t realize the impact it could have. I just wanted to signify my joy, but I did it wrong. Sorry.

1 Like