Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to automate Open Office via OleAutomation?
How to automate Open Office via OleAutomation? [message #1063194] Wed, 12 June 2013 15:15
Norbert Neubauer is currently offline Norbert NeubauerFriend
Messages: 1
Registered: June 2013
Junior Member
I am trying to start and automate Open Office in Java applet with SWT and OleAutomation. I know how to open document in OLE, however I have no clue how to do automation. In case of MS Word the object responsible for that was Word.Application, it doesn't seem to work the same way in case of Open Office.

In Open Office SDK, there is an example written in vbs.

'The service manager is always the starting point
'If there is no office running then an office is started up
Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager")

'Create the CoreReflection service that is later used to create structs
Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")

'Create the Desktop
Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")

'Open a new empty writer document
Dim args()	
Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)

'Create a text object
Set objText= objDocument.getText

'Create a cursor object
Set objCursor= objText.createTextCursor

'Inserting some Text
objText.insertString objCursor, "The first line in the newly created text document." & vbLf, false
  
'Inserting a second line
objText.insertString objCursor, "Now we're in the second line", false

...

I don't know how to create and use com.sun.star.ServiceManager
I hope you could help me porting this code so I can run it in JAVA and SWT.

Please note that UNO is not a solution for me.

Thank you in advance.
Previous Topic:Urgent Help needed regarding CSS mechanism in rcp application
Next Topic:SWT Scale - more than one selection
Goto Forum:
  


Current Time: Fri Apr 19 14:21:07 GMT 2024

Powered by FUDForum. Page generated in 0.01790 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top