[Solved] Error 429 ActiveX component can't create object

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

[Solved] Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi,

I found a number of questions on this but nothing that points to a definitive answer.

Using:

Code: Select all

  Dim oSM as object
  Set oSM = CreateObject("com.sun.star.ServiceManager")  'works OK
 
  Dim oCellRangeAddress As Object
  Set oCellRangeAddress = CreateObject("com.sun.star.Table.CellRangeAddress")  'fails
the second one gives the error 429 'ActiveX component can't create object'.

Looking around the internet this could be due to 'permisisons' (Win 10 tries to lock everything down) or a .dll / .ocx that isn't registered correctly.

Can anyone tell me if 'com.sun.star.Table.CellRangeAddress' references a particular .dll, etc, possibly a different one to '.ServiceManager'?

Regards
Peter
Last edited by Hagar Delest on Mon Jan 08, 2018 9:54 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.4 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Error 429 ActiveX component can't create object

Post by Villeroy »

http://www.openoffice.org/api/docs/comm ... dress.html
A CellRangeAddress is not an object. It is a struct of 5 integer numbers.

See "Passing a structure as a function arguments from VB" in http://www.kalitech.fr/clients/doc/VB_APIOOo_en.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi Villeroy,

Thanks, I'll have a play around with that.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi Villeroy,

I couldn't see it so after a query on a VB forum where the suggestion was to use 'Enum', I now have:

Code: Select all

(General)(Declarations)
Option Explicit

Private Enum CellInsertMode
    none
    DOWN
    Right
    rows
    Columns
End Enum

  Dim URL As String
  
  Dim oSM As Object             'Root object for accessing OpenOffice from VB
  Dim oDesk As Object           'First objects from the API
  Dim oDoc As Object            'First objects from the API
  Dim arg(1) As Object             'Ignore it for the moment !
  Dim OpenParam(1) As Object    'Parameters to open the doc

  Dim oSheets As Object
  Dim oSheet As Object
  Dim oRange As Object
  Dim oCell As Object


'-----------------------------

Private Sub Form_Load()
  On Error GoTo ErrorSub
  
  Set oSM = CreateObject("com.sun.star.ServiceManager")
  
  Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
  
  URL = "file:///D:/Open%20Office/test%201.csv"
  Set oDoc = oDesk.loadComponentFromURL(URL, "_blank", 0, OpenParam)

  Set oSheets = oDoc.getSheets()

  Set oSheet = oDoc.sheets(0)
  
  Dim oCRAddr As Object  'cellrangeAddress
  Set oCRAddr = oSM.Bridge_GetStruct("com.sun.star.table.CellRangeAddress")
  
  oCRAddr.sheet = 0
  oCRAddr.StartColumn = 1
  oCRAddr.StartRow = 1
  oCRAddr.EndColumn = 2
  oCRAddr.EndRow = 2
  
  'from OOo...  Sheet.insertCells(CellRangeAddress, com.sun.star.sheet.CellInsertMode.DOWN)
  Call oSheet.insertCells(oCRAddr, CellInsertMode.DOWN)

this still gives err 438 'Object doesn't support this property or method'.

In the 'imediate window' I can 'print CellInsertMode.Down' and it reports as "1", as expected.
I can also print oCRAddr.sheet, oCRAddr.StartRow, etc, all seems OK.

Any idea why I Still get the error please?

Regards
Peter
Last edited by Peterd51 on Mon Jan 08, 2018 10:28 am, edited 1 time in total.
OpenOffice 4.1.4 on Windows 10
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi,

I'm still poking around with this and I found:

uses of struct CellRangeAddress
Uses as Parameter
::com::sun::star::sheet::XCellRangeMovement::insertCells()

have I taken a wrong turn or would this be of any use to me?

I've tried in but, again, I get an error as I'm not sure of the exact format.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Error 429 ActiveX component can't create object

Post by Lupp »

You may have to create your oSM and oDesk.
I can neither tell from knowledge anything about VB nor can I test.
But the functional part of the code looking as if it is BASIC with some LibO/AOO API-calls looks somehow bureaucratic to me.
I simplified it to

Code: Select all

Sub Test()
oDoc = StarDesktop.LoadComponentFromURL(ConvertToURL("C:\Users\Wolfgang\Documents\3Arbeit\test\testsheet.ods"), "_blank", 0, Array())
oSheet = oDoc.Sheets(0)
Dim oCRAddr As New com.sun.star.table.CellRangeAddress
myCellInsertMode = 1
oCRAddr.Sheet = 0
oCRAddr.StartColumn = 1
oCRAddr.StartRow = 1
oCRAddr.EndColumn = 2
oCRAddr.EndRow = 2
oSheet.insertCells(oCRAddr, myCellInsertMode)
End Sub
and this worked as expected.

Dim oCRAddr As Object : This shouldn't cause an error, but, as Villeroy already told, a CellRangeAddress isn't of an object type, but of a specific UnoStruct type.
oCRAddr = CreateUnoStruct("com.sun.star.table.CellRangeAddress") also works.
URL = "file:///D:/Open%20Office/test%201.csv" : What are the spaces good for?

If you need to run the code from AOO BASIC because the VB bridge is inapt, you may place the code into a module (in my case Tests) of your AOO Standartd library and activate it like an OS command:

Code: Select all

"C:\Program Files\OpenOffice\program\soffice.exe" macro:///Standard.Tests.myTestMacro
(Adapt your soffice.exe path according to your system.)

I tested this with LibO V5.4.4 and it worked flawlessly.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi Lupp,

thanks for the suggestions, I'll try it later.

The code as it's written above works in VB5 right down to the last line where it calls the 'oSheet insertCells' and it fails at that point.

These are all 'objects' in VB, there's little else that they can be, but once they're 'passed' in the 'call' then OOo can refer to them as whatever it needs to.

I've been looking at the API Reference and I can't see 'insertCells' in the 'sheet' list. It doesn't set the 'c' in upper case as I would expect it to if it recognised the command.

The spaces in the URL are there as I prefer to name my folder as 'Open Office' rather than 'OpenOffice', same with filenames having a gap between the name and any numbers. It makes it easier for me to see them when I look in file explorer.

My eyes aren't a sharp as they used to be.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Error 429 ActiveX component can't create object

Post by Lupp »

Did you test replacing CellInsertMode.DOWN with a simple number 1?
I actually couldn't find a working way to access that constant by name. You may have a look into https://api.libreoffice.org/docs/idl/re ... 04d1ef605a . It's LibO, but that shouldn't matter.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Error 429 ActiveX component can't create object

Post by RoryOF »

Peterd51 wrote:Hi Lupp,

The spaces in the URL are there as I prefer to name my folder as 'Open Office' rather than 'OpenOffice', same with filenames having a gap between the name and any numbers. It makes it easier for me to see them when I look in file explorer.

My eyes aren't a sharp as they used to be.
In place of the spaces, you could experiment with underscores ("_"); it is not unknown for spaces in filenames or URLs to cause problems.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi Lupp,

I hadn't tried that perviously but when I did a few minutes ago it didn't make any difference.

Hi RoryOF, Thanks for the suggestion, something for me to bear in mind. Although here it was opening the file and I could see the stored data.

I had another suggestion from the VB5/6 forum to add an extra line:

Code: Select all

  Set oSheets = oDoc.getSheets()
  Set oSheet = oDoc.sheets(0)
  Set oSheet = oDoc.CurrentController.ActiveSheet     'select sheet 'inside' VB
 
this now working.

Thanks for all of your suggestions.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Error 429 ActiveX component can't create object

Post by Lupp »

Code: Select all

  Set oSheet = oDoc.sheets(0)
  Set oSheet = oDoc.CurrentController.ActiveSheet
If the second command works, but the first one doesn't, the brige is broken and cannot be trusted, imo. Or does VB break the convention concerning case insensitivity?
Are there means to inspect objects?
If so, what does an inspection of oSheet after the first command show (.AbsoluteName e.g.)?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: [Solved] Error 429 ActiveX component can't create object

Post by Peterd51 »

Hi Lupp,

we generally don't need to worry about case sensitivity in VB. The only time it affects me is where I grab some text and compare it with a variable:

Code: Select all

Text1= Name.Text    'set to 'Peter'

Text2="peter"

If Text1 = Text2 Then   'would be false
  ...
End If

'So I'd do:
Text1= LCase(Name.Text)    'set it to 'peter'

Text2="peter"

If Text1 = Text2 Then   'would be true
  ...
End If
Accessing filenames on the drive wouldn't be a problem, it would accepet anything.

I've just checked the Object broiwser and I can't see my objects (only those in the .DLLs) so I can't say if I could do any more with it. It's not something I've ever done before so I'll need to hit the books for a few hours.

One thing that's handy is after dimming something, like 'Dim Text1 as string', if I then type 'text1="A"' the first caracter gets changed to uppercase which tells me that the variable is set up and I've typed it correctly.

Which is why I queried 'oSheet.insertcells()' where I would expect the 'c' to be automatically changed to uppercase as that's the way it's been shown in the expamples provided to me.

But it's working now so I'll play around with it for a few days to see if I can copy and move cell ranges.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
Post Reply