List Info

Thread: Automation on Mac OS




Automation on Mac OS
user name
2006-09-13 11:04:53
Hi porters,

I did a quick search on users mailing list and found
nothing, so i come 
here as it is Mac related.
Sorry if it is off-topic.


My question :
I'm writing a software with a RAD tool (4th Dimension) and
i would like 
my software to communicate with OpenOffice :
I already can :
- launch openoffice
- open a list of documents
with a command like "osacript path/to/OpenOffice
path/to/document.odt"


But how can i
- open a new document from template (template name as
parameter)
- execute a macro (macro name as parameter)
?


Thanks for any information,

Michel

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeporting.openoffice.org
For additional commands, e-mail: dev-helpporting.openoffice.org

Automation on Mac OS
user name
2006-11-09 09:52:31
Hi porters,

I found a solution to my problem, and i would like to share
it :

you need to modify the applescript located in 
"OpenOffice.app/Contents/Resources/Scripts/Main.spt&quo
t; :
just add the following code :
---------------------------------------------
on macro(theMacro)
	if (preRun()) then
		openMacro(theMacro)
	end if
	
end macro

on openMacro(aMacro)
	set theDisplay to startXServer()
	if (theDisplay is equal to "error") then
		return
	end if
	set theEnv to "DISPLAY=" & theDisplay &
" ; export DISPLAY; "
	set theCmd to "sh "" & POSIX path of
getOOProgramPath() & "soffice" & 
"" "
	set theScript to theEnv & theCmd & "
'macro:///" & aMacro & "' " &
"  
&>/dev/null & echo $!"
	-- display dialog theScript
	do shell script theScript
end openMacro
---------------------------------------------

That's all !

Now, we can call OpenOffice and ask it to execute a macro
like this :

tell application "OpenOffice.org2.0"
	macro("Standard.Module1.myMacro(aParam)")
end tell


Note :
if you send a file's path, you need to write it the unix
way, not the 
mac way :
- mac way :  "absolute:path:to:the:file"
- unix way : "/Volumes/absolute/path/to/the/file"

example of a call with a file as param :
tell application "OpenOffice.org2.0"
	macro("Standard.Module1.myConvert(/Volumes/absolute/pa
th/to/the/file)")
end tell



Hope this helps,


Michel Renon


Le 13 sept. 06, à 13:04, michel RENON a écrit :

> Hi porters,
>
> I did a quick search on users mailing list and found
nothing, so i 
> come here as it is Mac related.
> Sorry if it is off-topic.
>
>
> My question :
> I'm writing a software with a RAD tool (4th Dimension)
and i would 
> like my software to communicate with OpenOffice :
> I already can :
> - launch openoffice
> - open a list of documents
> with a command like "osacript path/to/OpenOffice
path/to/document.odt"
>
>
> But how can i
> - open a new document from template (template name as
parameter)
> - execute a macro (macro name as parameter)
> ?
>
>
> Thanks for any information,
>
> Michel
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribeporting.openoffice.org
> For additional commands, e-mail: dev-helpporting.openoffice.org
>
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeporting.openoffice.org
For additional commands, e-mail: dev-helpporting.openoffice.org

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )