Openoffice's macros

Openoffice's macros

Postby wzaf » Thu Apr 15, 2010 4:12 pm

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

Code: Select all  Expand view
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
wzaf
 
Posts: 38
Joined: Tue Sep 30, 2008 11:16 am

Re: Openoffice's macros

Postby xProgrammer » Thu Apr 15, 2010 11:09 pm

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  Expand view
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
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Openoffice's macros

Postby wzaf » Fri Apr 16, 2010 8:07 am

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
wzaf
 
Posts: 38
Joined: Tue Sep 30, 2008 11:16 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests