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

Start macro from commad line

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





PostPosted: Mon Apr 19, 2004 12:20 am    Post subject: Start macro from commad line Reply with quote

i start a text document whit the commad line:

<path>\soffice.exe -o <document.txt>

the question is:
Can I start also a macro to command line?

thanks
Back to top
elehenaff
Power User
Power User


Joined: 16 Apr 2004
Posts: 76
Location: paris - france

PostPosted: Mon Apr 19, 2004 12:31 am    Post subject: Reply with quote

yes!
i did by storing my macro in the soffice macro subtree and launched it by typing :

H:\>"C:\Program Files\OpenOffice.org1.1.1\program\soffice.exe" macro:///Standard.Module1.message(2)

as u can see, u can even pass parameters to your macro.
Back to top
View user's profile Send private message Visit poster's website
dukevir
Guest





PostPosted: Mon Apr 19, 2004 6:21 am    Post subject: Reply with quote

thanks elehenaff Very Happy
Back to top
Peter O
Guest





PostPosted: Fri Jun 18, 2004 12:21 am    Post subject: additional question Reply with quote

Starting a macro this way works just fine.
But how do I make OpenOffice close again after the macro has finished ?

I'm trying to manipulate around 1000 documents and I don't think that having 1000 copies of OpenOffice running on my system is going to be very efficient.
Back to top
Guest






PostPosted: Fri Jun 18, 2004 1:50 am    Post subject: idea Reply with quote

Maybe you could put that in the end of the macro code? self.close() or something?
Back to top
Peter o
Guest





PostPosted: Fri Jun 18, 2004 2:02 am    Post subject: Reply with quote

Sorry, this gives "BASIC runtime error Object variable not set" Crying or Very sad
Back to top
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Fri Jun 18, 2004 5:54 am    Post subject: Reply with quote

use thisComponent.close(true) and then Stardesktop.terminate() at the end.
This should do what you want.
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
DannyB
Moderator
Moderator


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

PostPosted: Fri Jun 18, 2004 6:17 am    Post subject: Re: additional question Reply with quote

Peter O wrote:
Starting a macro this way works just fine.
But how do I make OpenOffice close again after the macro has finished ?

I'm trying to manipulate around 1000 documents and I don't think that having 1000 copies of OpenOffice running on my system is going to be very efficient.


It is not necessary to make OOo close after each time you call a macro from the command line. Each command that runs soffice.exe with a macro will run the macro within the copy of OOo that is already open and running. You will not end up with 1000 copies running.

Only at the end, once, do you need to make OOo quit. You can do this by calling a second macro that makes OOo quit.
http://www.oooforum.org/forum/viewtopic.php?t=9942
Depending on your needs, it may not even be necessary for you to close OOo at the end of the 1000 document conversion.

Another possibility is that you might want to close OOo after every, say, 50 documents are converted. That way, on the 51st document, 101st document, etc., a new copy of OOo is launched.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
fgomes
Newbie
Newbie


Joined: 12 Aug 2004
Posts: 3

PostPosted: Thu Aug 12, 2004 3:28 pm    Post subject: Can I put more than one argument for the macro? Reply with quote

Using the command line macro calling, can I put more than one argument? It worked for me with one paramenter but when I tried to put 2 arguments in the macro, and then calling it from the command line the second paramenter is not passed.
Command line:
soffice macro:///Standard.Module1.Macro1("abc", "def")
Macro:
Sub Macro1(a As String, b As String)
MsgBox a & " " & b
End Sub

Is it possible to do it? Am I doing something rong?

Thanks in advance

Fernando
Back to top
View user's profile Send private message
sasol
Newbie
Newbie


Joined: 13 Aug 2004
Posts: 2

PostPosted: Fri Aug 13, 2004 4:08 am    Post subject: Reply with quote

what if my macro is in some specific file, eg test.sxc??
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 Aug 13, 2004 5:38 am    Post subject: Reply with quote

sasol wrote:
what if my macro is in some specific file, eg test.sxc??


Do this....

Code:
soffice "C:\Documents and Settings\dbrewer\Desktop\test.sxc" "macro://test/Standard.Module1.MeowMix()"

(Note, the above is one long command line, not multiple lines.)

First you get a dialog that complains about the document having macros, but not being in the path of documents trusted to run macros. Click Run.

Then you get the MsgBox, because the macro code in the document sez...
Code:
Sub MeowMix
   MsgBox "MeowMix"
End Sub

_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
HexTA
General User
General User


Joined: 06 May 2006
Posts: 13

PostPosted: Fri May 12, 2006 7:47 am    Post subject: Reply with quote

Quote:

Do this....
Code:
soffice "C:\Documents and Settings\dbrewer\Desktop\test.sxc" "macro://test/Standard.Module1.MeowMix()"
Code:
Sub MeowMix
MsgBox "MeowMix"
End Sub


doesn't work Sad
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: Fri May 12, 2006 8:20 am    Post subject: Reply with quote

See :
simple command line question http://www.oooforum.org/forum/viewtopic.phtml?t=2619&highlight=
How to convert Word -> PDF from the command line http://www.oooforum.org/forum/viewtopic.phtml?t=3772
Creating PDF at commandline (with compression) http://www.oooforum.org/forum/viewtopic.phtml?t=33047&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
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