[CONNECT U16 VBA] Method 'CreatePropertyHandler' of object '_application' failed

I have a VBA script designed under V8i and which worked very well on this version.
By wanting to reuse it under CONNECT I have an error that occurs at each execution on my DGN.

Rub-time error '-2147467259 (80004005)'
Method 'CreatePropertyHandler' of object '_application' failed

An example of code reproducing the error

Dim oPH As PropertyHandler
Dim sArray() As String

'Store all cells in array
Set oScanCriteriaCell = New ElementScanCriteria
oScanCriteriaCell.ExcludeAllTypes
oScanCriteriaCell.IncludeType msdElementTypeCellHeader
oScanCriteriaCell.IncludeType msdElementTypeSharedCell
oScanCriteriaCell.ExcludeNonGraphical
Set oCells = ActiveModelReference.Scan(oScanCriteriaCell)
elArrayCell = oCells.BuildArrayFromContents

'Loop in cells to extract sub shape
For i = LBound(elArrayCell) To UBound(elArrayCell)
    Set ee = elArrayCell(i).AsCellElement.GetSubElements
    elArraySubElement = ee.BuildArrayFromContents
    
    For j = LBound(elArraySubElement) To UBound(elArraySubElement)
        If elArraySubElement(j).IsShapeElement = True Then
            Set oPH = CreatePropertyHandler(elArraySubElement(j).AsShapeElement)
            oPH.SelectByAccessString "Count"
            nEles = oPH.GetValue
            ReDim sArray(0 To nEles - 1) As String
        End If
    Next
Next

An example of the type of object on which this occurs

There have been breaking changes between V8i and CONNECT which could explain this problem? Or is it an internal bug?

Parents
  • Thanks for yours answers. 

    there is a known issue with method CreatePropertyHandler and subelements of cells. This issue is addressed as Bug # 777974 and will be fixed with the next CONNECT Update 17.

    So it's a problem related to the version of Microstation.

    What about this code, not based on PropertHandler (and not using memory inefficient array):

    Thanks for your proposition. The sample code is actually a small part from an old script. I'm not a VBA developer but from what i understand it is necessary to use PropertyHandler to access at SelectByAccessString("Segments[1].Start").

  • Hi John,

    I agree with Jan, PropertyHandler is not required with this example, the MicroStation VBA object library has methods to directly retrieve the shape vertices.

    A code snippet like this could be used to read the vertex coordinates:

    Dim oShape As ShapeElement
    Dim pVert() As Point3d
    '...
    
    pVert = oShape.GetVertices
    For i = LBound(pVert) To UBound(pVert)
        Debug.Print pVert(i).x, pVert(i).y, pVert(i).z
    Next

    Best regards,

    Artur

Reply
  • Hi John,

    I agree with Jan, PropertyHandler is not required with this example, the MicroStation VBA object library has methods to directly retrieve the shape vertices.

    A code snippet like this could be used to read the vertex coordinates:

    Dim oShape As ShapeElement
    Dim pVert() As Point3d
    '...
    
    pVert = oShape.GetVertices
    For i = LBound(pVert) To UBound(pVert)
        Debug.Print pVert(i).x, pVert(i).y, pVert(i).z
    Next

    Best regards,

    Artur

Children
No Data