FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Openoffice's macros
Posts: 38
Joined: Tue Sep 30, 2008 11:16 AM
Openoffice's macros
Posted: Thu Apr 15, 2010 04:12 PM
Hi all,
I want to call an openoffice macro from fwh .
I use the following commands:

Code (fw): Select all Collapse
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
Posts: 464
Joined: Tue May 16, 2006 07:47 AM
Re: Openoffice's macros
Posted: 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 (fw): Select all Collapse
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
Posts: 38
Joined: Tue Sep 30, 2008 11:16 AM
Re: Openoffice's macros
Posted: Fri Apr 16, 2010 08: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

Continue the discussion