Update node text

Hi! I'm updating some text from excel to Microstation. Until now I'd been able to update Text and Tags, but I have problems with Text nodes, here is my code:

If myWS.Cells(FileRow, 2) = "NODE" Then
Set myNode = myDGN.GetElementByID(myID)     'Store ID High and Low
myNode.TextLine(1) = myWS.Cells(FileRow, 4)    'Store new Textnode Value
myNode.Rewrite                                                            'Write TextNode
End If

The error is "Run time error -69652(ffeefec) at the line three. I have been looking for information regarding the text nodes, but I can't find something similar, even in the help files.

Thanks!

Parents
  • Debug.Assert is your Friend

    myNode.TextLine(1) = myWS.Cells(FileRow, 4) 'Store new Textnode Value

    You need to be sure that myNode.TextLine(1) exists, and you need to be sure that myWS.Cells(FileRow, 4) is a valid range.

    Use VBA's Debug.Assert to validate your assumptions:

    
    Dim nTextLine As Long
    nTextLine = 1
    Debug.Assert nTextLine <= myNode.TextLinesCount
    myNode.TextLine(nTextLine) = ...
    ...
    Dim cellText As String
    cellText = myWS.Cells(FileRow, 4)
    Debug.Assert 0 <= Len (cellText)
    Debug.Print "Assign '" & cellText & "' to TextLine(" & CStr(nTextLine) & ")"
    myNode.TextLine(1) = cellText
    

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon, thanks.

    They both exist, I rewrite this code at Excel 

    Dim myNode As TextNodeElement

    If myWS.Cells(FileRow, 2) = "NODE" Then
    Set myNode = myDGN.GetElementByID(myID) 'Store ID High and Low
    MsgBox (myNode.TextLine(1))
    MsgBox (myWS.Cells(FileRow, 4))
    myNode.TextLine(1) = myWS.Cells(FileRow, 4) 'Store new Textnode Value   HERE IS WHEN DE ERROR START
    myNode.Rewrite 'Write TextNode
    End If

    The message boxes show me exactly the value of the node (In my case is "A") and the value of the cell (In my case is "NODE123") but the error is the -2147218399 "Bad element"

  • Debug.Print

    Roberto Cano said:

    
    MsgBox (myNode.TextLine(1))
    MsgBox (myWS.Cells(FileRow, 4))
    

    Debug.Print comes in useful here. The following code is similar, but the text appears in VBA's Immediate window:

    
    Debug.Print "myNode.TextLine(1): " & myNode.TextLine(1)
    Debug.Print "myWS.Cells(FileRow, 4): " & myWS.Cells(FileRow, 4)

     
    Regards, Jon Summers
    LA Solutions

Reply Children