| View previous topic :: View next topic |
| Author |
Message |
dukevir Guest
|
Posted: Mon Apr 19, 2004 12:20 am Post subject: Start macro from commad line |
|
|
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

Joined: 16 Apr 2004 Posts: 76 Location: paris - france
|
Posted: Mon Apr 19, 2004 12:31 am Post subject: |
|
|
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 |
|
 |
dukevir Guest
|
Posted: Mon Apr 19, 2004 6:21 am Post subject: |
|
|
thanks elehenaff  |
|
| Back to top |
|
 |
Peter O Guest
|
Posted: Fri Jun 18, 2004 12:21 am Post subject: additional question |
|
|
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
|
Posted: Fri Jun 18, 2004 1:50 am Post subject: idea |
|
|
| Maybe you could put that in the end of the macro code? self.close() or something? |
|
| Back to top |
|
 |
Peter o Guest
|
Posted: Fri Jun 18, 2004 2:02 am Post subject: |
|
|
Sorry, this gives "BASIC runtime error Object variable not set"  |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Fri Jun 18, 2004 5:54 am Post subject: |
|
|
use thisComponent.close(true) and then Stardesktop.terminate() at the end.
This should do what you want. _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Jun 18, 2004 6:17 am Post subject: Re: additional question |
|
|
| 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 |
|
 |
fgomes Newbie

Joined: 12 Aug 2004 Posts: 3
|
Posted: Thu Aug 12, 2004 3:28 pm Post subject: Can I put more than one argument for the macro? |
|
|
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 |
|
 |
sasol Newbie

Joined: 13 Aug 2004 Posts: 2
|
Posted: Fri Aug 13, 2004 4:08 am Post subject: |
|
|
| what if my macro is in some specific file, eg test.sxc?? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Aug 13, 2004 5:38 am Post subject: |
|
|
| 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 |
|
 |
HexTA General User

Joined: 06 May 2006 Posts: 13
|
Posted: Fri May 12, 2006 7:47 am Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
SergeM Super User

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