Run Macro from Command Line

Will experiment with later. Let you know if I find any solution.

One other suggestion. While not the best solution, at the end of the macro add ThisComponent.close(1). That will close the blank .odt & still leave the report visible.

Edit: Just tried at beginning of macro and blank screen appeared for shorter amount of time. Report still generated.

Yes @Ratslinger, that’s another option, not ideal but its better than nothing…thanks :slight_smile:

Hello

may be you missed that there need to be three /// after the keyword macro - try:

soffice "C:\Users\nuno\AppData\Roaming\LineMap.odb" macro:///LineMap/Reports.Report.genRep

If the answer is correct or helped you to fix your problem, please click the check mark (:heavy_check_mark:) next to the answer.

Unfortunately that doesn’t change anything. Same behaviour. No macro being fired.

Thanks

Ah - now I see. your path doesn’t fit to the format specification Library.Module.Macroname

@anon73440385: the macro: URI does fit to //authority/Library.Module.Macroname spec - where authority is docname; so it possibly should work - but it doesn’t (also in my testing)…

It also only works form me, if I put the macro into global section “My Macros”

Mike have you tried and is not working as well?

There’s something wrong I believe…

What I need is to generate a report that is inside that odb file! I have a macro in My Macros that receive a doc name (the odb in that case) and a report name and it works, the problem is I have to install libreoffice in multiple PC’s and I really don’t like the idea of install and then import Macros if I can have a macro inside a file.

I have debugged, and in SfxMacroLoader::loadMacro, the call to SfxObjectShell::GetFirst() returns nullptr - it means that the open database isn’t listed among open shells - and thus doesn’t offer the expected functionality (unlike Writer or Calc components). You may file an enhancement request to add such functionality to Base.

1 Like

Ok Mike…Thank you so much…In that case I can create a odt dummy file with a macro where I pass the odb file path and report name and it solves my problem…Thanks you again

But possibly better assign the macro in the DB to the Open Document event?

I thought about that. But then how can I pass the name of the report that I want to open?

Then please do file a request to bug tracker, and post a ref# here.

Bug Ref

@mikekaganski, Can I ask you just one more thing? I’m trying to open this dummy,odt file that I created which is just a black file in background (no GUI) but it doesn’t work as well…

soffice --headless --invisible --nologo “C:\Users\nuno\AppData\Roaming\dummy.odt”

Thanks

Doesn’t work in what way?

It launch the file normally…it bring the window to the front! Maybe I’m wrong but I was expecting to run the file without actually see it.

In 6.3, it runs without displaying anything; but I remember 6.2 working the way you describe. However, in no version will you succeed in calling LO with --headless, and then have something opened and properly working interactively: the --headless is designed for server mode, and even if it would open something visible, it would prevent dialogs, and many more. So - if you want the program to run interactively, then don’t use --headless. And yes, you likely won’t be able to open a document hidden that way.

Command is “Call”. If I’m understand the question aright, I call up other macro’s or sub’s, in other sub’s, by the command “call” then the name of sub or macro. If a crated macro (sub) is named “Open_Box_2”, I type a line in a sub… Call “Open_Box_2”. But all that is done, works, when all sub’s (or macro’s) are in the same file.