Skip to content

OpenOffice automation

Forums Forums SIMPOL Programming OpenOffice automation

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #190
    Ian Macpherson
    Participant

    I was wondering whether anybody had tried automating OpenOffice within SIMPOL We all know that it is possible to a certain degree with Micorosoft Word ( apart from not being able to address individual Bookmarks) There is a demo on the web at http://www/openoffice.org/udk/common/man/tutorial/writerdemo.html that explains a lot The following code does it with VB Set oSM = CreateObject(“com.sun.star.ServiceManager”) Set oDesk = oSM.createInstance(“com.sun.star.frame.Desktop”) Set oDoc = oDesk.loadComponent FromURL(“file:///c/simpol/…../test.doc”, “_blank”, 0, arg()) Apparently arg() relates to the parameters Hidden, ReadOnly etc & for me is obscure for the moment in SB you can say DIM wo as Object SET wo = CREATEOBJECT(“com.sun.star.ServiceManager”) …This creates a Server object DIM oDesk as Object SET oDesk = wo.createInstance(“com.sun.star.frame.Desktop”) This creates an AuitoObject in the Server object I didn’t get through the oDoc because I wasn’t sure how to handle the arg thing In SIMPOL you try the following I guess e = 0 oSM =@ wxautomation1.new(createinstance=”com.sun.star.ServiceManager”, error=e) if oSM =@= .nul s = “Error number ” + .tostr(e, 10) + ” creating new OpenOffice instance{d}{a}” else oDesk =@ oSM.callmethod(method=’createInstance(“com.sun.star.frame.Desktop”)’, error =e) if e != 0 and e != 531 s = “Error number ” + .tostr(e, 10) + ” getting Desktop {d}{a}” else s = “com.sun.star.reflection.CoreReflection” oOCR =@ oSM.callmethod(method=”createInstance(s)”, error =e) if e != 0 and e != 531 s = “Error number ” + .tostr(e, 10) + ” getting Corereflection {d}{a}” else filename = “file:///c:/simpol/My Projects/ole2word/bin/test.odt” oDesk.callmethod(method=’loadComponentFromURL(filename, “_blank”, 0, arg())’, error=e) if e != 0 and e != 531 An oSM object is created by the first line of code & if you hit Ctrl Alt Supp you see an entry for soffice.bin and soffice.exe but that is as far as it gets. The oDesk comes out as .nul so you can’t address it to try and open a document but the error is 0. The oOCR does the same I also tried oDesk =@ oSM.getobject(property = etc but got thrown out Anybody any ideas please Regards to all Ian Macpherson

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.