Openoffice's macros

Post Reply
wzaf
Posts: 38
Joined: Tue Sep 30, 2008 11:16 am

Openoffice's macros

Post by wzaf »

Hi all,
I want to call an openoffice macro from fwh .
I use the following commands:

Code: Select all

oService   := CreateObject( "com.sun.star.ServiceManager" )
oDesktop := oService:CreateInstance( "com.sun.star.frame.Desktop" )

aVet:={}
oDoc    := oDesktop:LoadComponentFromURL( "file:///" + StrTran( myfilename , "\", "/" )     , "_blank", 0, aVet )

oDispatcher:= oService:CreateInstance( "com.sun.star.frame.DispatchHelper" )
oDispatcher:executeDispatch(oDoc:GetCurrentController():GetFrame(), ".uno:runmacro", "mymacro", 0, Array() )
...
But doesn't work .
Can anyone help me ?

Tanks,
Wzaf
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Openoffice's macros

Post by xProgrammer »

Hi wzaf

I can't troubleshoot your code as I am in a Linux environment but I can show you an ugly way of doing it. This code works for me - but it is in a utility that only I run so it doesn't matter that it is ugly. I use a file as a semaphore to tell when the process has finished. If you are desperate enough to use such an ugly method I can supply more information if needed.

Code: Select all

sOSCommand := "soffice " + sWPDocName + ' "macro:///Standard.Module1.SaveTextAndPDF(' + sTextDocName + ')"'
RUN ( sOSCommand )
SaveTextAndPDF is a macro that opens an OpenOffice document named sTextDocName and saves it both as a text file and as a pdf. I use the text file to extract key data (in this case things like patient name, DOB, procedure etc) that can be used to access the document stored as a pdf in an archive.

Regards
xProgrammer
wzaf
Posts: 38
Joined: Tue Sep 30, 2008 11:16 am

Re: Openoffice's macros

Post by wzaf »

Tank you for your answer xProgrammer!
But your solution ( run openoffice with command line argument that start a macro) is not valid for my needs.
I 've to start several macros within the same document.....

Best regards

Wzaf
Post Reply