How to use COM in OO?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

How to use COM in OO?

Post by grnhorn »

Does anyone have an example of using COM in OO? I found 1 link to tcom, but that is not part of OO or Star BASIC.

Thanks...
OOo 2.4.X on Ms Windows XP
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: How to use COM in OO?

Post by B Marcelly »

Hi,
Try this link : VBx OOo tools
______
Bernard
Last edited by B Marcelly on Tue Feb 15, 2011 12:42 pm, edited 1 time in total.
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: How to use COM in OO?

Post by grnhorn »

Thanks Bernard. I will have to spend some time on this. Apparently OO does not have a way of connecting to documents that are not exposed like VBA has. I have tried using DDE and whatever, but it has all failed. I am wondering if OO is going to correct this issue??? DDE is no longer supported by MS and it started failing years ago. I do some PLC work and a connection is required for data gathering. If OO doesn't do something, they are going to lose ground that they have gained.

I will get back in a few days.
OOo 2.4.X on Ms Windows XP
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: How to use COM in OO?

Post by B Marcelly »

Hi,
grnhorn wrote:Apparently OO does not have a way of connecting to documents that are not exposed like VBA has.
I'm not sure to understand what you mean.
If you mean load a document in hidden mode and handle it, of course that's possible with COM.
If you mean embedding OOo in a frame of another application, I have never succeeded in doing this. Perhaps others have.

I am not aware of any OOo development in the works to improve COM.
______
Bernard
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: How to use COM in OO?

Post by grnhorn »

I meant to say that OO does not have a way to link to hidden documents using OO BASIC. OO apparently needs an interface like VBA to communicate with its own documents. What I am seeing, if I am correct, OO does not have any COM capabilities because it does not support object creation (Set OpenOffice = CreateObject("com.sun.star.ServiceManager"). I also assume that StarBasic does not support COM????

I am new at OO and have a long ways to go.
OOo 2.4.X on Ms Windows XP
ms777
Volunteer
Posts: 177
Joined: Mon Oct 08, 2007 1:33 am

Re: How to use COM in OO?

Post by ms777 »

grnhorn,

I am also not completely sure what you are targeting at, but constructions like this work perfectly fine in OO Basic:

Code: Select all

  Sub Main 
  oleService = createUnoService("com.sun.star.bridge.OleObjectFactory") 
  oIE = oleService.createInstance("InternetExplorer.Application") 
  oIE.visible = true 
  oIE.Navigate("http://somehwhere/") 
  while oIE.Busy 
    wait(50) 
    wend 

  oDoc = oIE.Document 
  oInputs   =       oDoc.getElementsByTagName("INPUT") 

  oInputPass= oInputs.item(0) 
  msgbox "Now it will submit ..." 
  oInputPass.click 

End Sub
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: How to use COM in OO?

Post by grnhorn »

My actual target is sCalc in that I want to be able to manipulate the data in 1 sheet from 2 different sources while the target is not visible and accessible to the user.

I took a look at your example and I guess I am a little more confused by the following 2 examples:

Code: Select all

  oInputs   =       oDoc.getElementsByTagName("INPUT")
  oInputPass.click
I used xRay and 'getElementsByTagName' did not show up for oDoc and 'click' did not show up for 'oInputPass'. Where did you get these from? Also, I could not find a method for closing IE.

Thanks for your help...
OOo 2.4.X on Ms Windows XP
Post Reply