| View previous topic :: View next topic |
| Author |
Message |
ColD Newbie

Joined: 09 Sep 2003 Posts: 1
|
Posted: Wed Sep 10, 2003 2:07 am Post subject: simple command line question |
|
|
I have what I think is a very simple question?
I want to know the syntax required to run a Macro from the command line without opening a staroffice window.
The code for the macro is in a module called Module1. This is held in a structure called Standard which in turn attached to a file called myMacro.bas
I think it should be something along the lines of the following:
soffice -invisible macro:///myMacro.bas.Standard.Module1.Main
I'd be grateful for any help.
 |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Oct 24, 2003 8:34 am Post subject: |
|
|
I just invoked a macro from the command line, when launching soffice.exe by using this syntax....
| Code: | | soffice "macro:///Standard.Module1.HelloWorld()" |
Previously, I had created a HelloWorld() function in the Module1 module of the Standard library of the soffice.
| Code: | Sub HelloWorld()
MsgBox( "Hello World" )
End Sub |
The "macro://" specifies the type of url. The next slash means start at the "root" of the macros.
It may even be possible to pass arguments to a macro. See this post...
http://www.oooforum.org/forum/viewtopic.php?p=11794#11794
Clearly, I've demonstrated that you can run macros that are stored under soffice. I do not know whether macros can be run from a document when launching OOo. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Oct 24, 2003 11:01 am Post subject: |
|
|
It is possible to pass parameters to a macro when starting a macro by launching OOo from the command line.
Here is the command I used to launch OOo (on WinXP).
| Code: | | soffice "macro:///Standard.Module1.SubWithParams(meow mix)" |
In OOo, I created a macro as follows
| Code: | Sub SubWithParams( cMessageParam )
MsgBox( cMessageParam )
End Sub |
under soffice, in the Standard library in the Module1 module.
In the URL above, I was rather surprised that I did not need to quote my parameter? This bears further investigation. What if I wanted to macro to receive two parameters? Could it? _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Sat Oct 25, 2003 1:46 pm Post subject: |
|
|
The above technique also works to run a Macro in OOo on Linux. (OOo 1.1.0 final.)
Command entered, while OOo is already running!
| Code: | | /opt/OpenOffice.org1.1.0/program/soffice "macro:///DannyB.Module1.DB_ShowParams(meow, mix)" |
There is a preexisting macro already in OOo....
| Code: | Sub DB_ShowParams( a, b )
MsgBox( a + "--" + b )
End Sub
|
The word "meow" went to parameter 'a', and "mix" went to parameter 'b'.
Especially interesting is that this worked even though OOo was already running with documents open. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Dujo General User

Joined: 12 Jul 2005 Posts: 22
|
Posted: Tue Jul 12, 2005 6:17 am Post subject: Tryout |
|
|
Hello,
I'm also trying to launch a macro stored in a file, from the command line.
Assuming you have a macro in c:\tmp\macro.sxw
I Tried
macro:///c:/tmp/macro.sxw.module.macro
macro:///c:/tmp/[macro.sxw].module.macro
No one is working, and openoffice doesn't show any error message.
Do I need to convert the " :" in "|" ?
Like macro:///c|/tmp/macro.sxw.module.macro
Any help would be aprreciated
Thank you
Dujo |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
Dujo General User

Joined: 12 Jul 2005 Posts: 22
|
Posted: Thu Jul 14, 2005 1:18 am Post subject: |
|
|
I copy paste the solution from one of the links above :
| Code: | | soffice "C:\Documents and Settings\dbrewer\Desktop\test.sxc" "macro://test/Standard.Module1.MeowMix()" |
It works fine for me
Thanks
Dujo |
|
| Back to top |
|
 |
|