OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

simple command line question

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
ColD
Newbie
Newbie


Joined: 09 Sep 2003
Posts: 1

PostPosted: Wed Sep 10, 2003 2:07 am    Post subject: simple command line question Reply with quote

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.
Smile
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Oct 24, 2003 8:34 am    Post subject: Reply with quote

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
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Oct 24, 2003 11:01 am    Post subject: Reply with quote

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
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Sat Oct 25, 2003 1:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dujo
General User
General User


Joined: 12 Jul 2005
Posts: 22

PostPosted: Tue Jul 12, 2005 6:17 am    Post subject: Tryout Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Jul 13, 2005 8:22 am    Post subject: Reply with quote

See also
Start macro from command line http://www.oooforum.org/forum/viewtopic.phtml?t=7975
Run macro from document from shell :http://www.oooforum.org/forum/viewtopic.phtml?t=6808
Run macro on form load : http://www.oooforum.org/forum/viewtopic.phtml?t=6844
Invoke an OO macro from shell http://www.oooforum.org/forum/viewtopic.phtml?t=17143&highlight=
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Dujo
General User
General User


Joined: 12 Jul 2005
Posts: 22

PostPosted: Thu Jul 14, 2005 1:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group