[Solved] Can't execute macro in file.ods from command line

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
onidarbe
Posts: 84
Joined: Thu Nov 29, 2007 8:03 pm
Location: Belgium, Mechelen

[Solved] Can't execute macro in file.ods from command line

Post by onidarbe »

In my Calc-file I have the basic macro:
Sub sMySub
msgbox "hello"
End Sub

I tried following lines in the XP - command window while in the map "C:\Program Files\OpenOffice.org 3\program>"

soffice.exe "macro:///Standard.Module1.sMySub"
soffice.exe "macro:///[My File.ods].Standard.Module1.sMySub"
soffice.exe "C:\My Documents\My File.ODS" "macro:///Standard.Module1.sMySub"
soffice.exe "C:\My Documents\My File.ODS" "macro:///[My File.ods].Standard.Module1.sMySub"
soffice.exe "C:\My Documents\My File.ODS" "macro:///My File.ods.Standard.Module1.sMySub"

Nothing works except switching the active window to my already running "My File.ods" with the last 3 examples above...

What am I doing wrong?
Attachments
macro run command.JPG
Last edited by onidarbe on Sun May 24, 2009 10:24 pm, edited 1 time in total.
OOo 3.1.X on Ms Windows XP
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Can't execute oobasic-macro in file.ods from command line

Post by B Marcelly »

Hi,

Code: Select all

soffice.exe "C:\My Documents\MyFile.ODS" "macro://MyFile/Standard.Module1.sMySub"
And avoid using spaces and national characters in the file name.
______
Bernard
User avatar
onidarbe
Posts: 84
Joined: Thu Nov 29, 2007 8:03 pm
Location: Belgium, Mechelen

Re: Can't execute oobasic-macro in file.ods from command line

Post by onidarbe »

Thank you B Marcelly, I've spend hours looking for this and it's so obvious :knock:

It even works with spaces in the name ;-)
OOo 3.1.X on Ms Windows XP
abhiabhi_84
Posts: 46
Joined: Wed Nov 19, 2008 7:54 pm

Re: [Solved] Can't execute macro in file.ods from command line

Post by abhiabhi_84 »

Hi,

Is it then possible to run a OO macro within a file "test123.ods", without opening the file? or even without getting a message for "ENABLE MACROS"?

I could run a macro through command line, but i dont want calc file to open.

Any way o do it?

Abhi
OOo 2.3.X on Ms Windows XP
User avatar
antekg
Posts: 14
Joined: Sat Oct 17, 2009 10:03 pm
Location: Poland, Warsaw

Re: [Solved] Can't execute macro in file.ods from command li

Post by antekg »

Code: Select all

"c:\Program Files (x86)\OpenOffice 4\program\soffice.exe" -invisible "macro:///Standard.Module1.Main"
No document file is specified and opened. However, the macro must reside in "My macros" container.
AOO 4.1.4 (Polish) on Windows 10 (64b) / AOO 4.1.0 on Windows Vista / (LibreOffice on Mageia Linux)
Post Reply