Run Macro from Command Line

@nSeixas,

Here is why I asked. Instead of having a macro in an .odt calling a macro in an .odb, possibly eliminate the .odb macro and just have one from an odt. Have opened Base reports from Writer using the macro by @Kridtbandit in this post → how to open Base reports based on queries in standalone.

Don’t yet comprehend all your needs (don’t think I need to either) but possibly this may be of use to you. Seems it has some potential for your situation.

@Ratslinger that´s what I tried, and it worked (just one macro in a blank odt file), the problem is that it will open the odt file (blank) and the report output file…not ideal!

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.