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!
Unknown said: Is there a work around to this ?
The other thread discussed this problem in the context of TextNodeElements in a cell. Apparently a TR was raised — maybe you can ask him for the number. File your own Service Request tied to that TR number: the more SRs there are linked to a TR, the higher its profile (one hopes).
Regards, Jon Summers LA Solutions
Dea Jon,
Is there a work around to this ?
"as luck would have it" I run into the same problem on Friday. My text node is part of a cell I didnot/cannot create the cell. I just need to change thte contents of the single line of the text node.
Making any changes tot eh text node fails. Geting a new object based on the element id and then editing it also fails when the text node changes.
I have texted with V8i and V8i Beta 2 both have the same issue.
Best Regards,
Ian Emery
Unknown said:
If you look at this thread trouble with TextNodeElements, you will find that others have had problems with the TextNodeElement and VBA in the context of a CellElement that contains a TextNodeElement. According to their evidence, the problem occurs with V8i and not previous versions of MicroStation.
Hi Romaca,
I use the below snippet to test TextNodeElement.TextLine(1), all work fine.
Sub Macro1() Dim myNode As TextNodeElement Set myNode = ActiveModelReference.GetElementByID(DLongFromLong(2341)) myNode.TextLine(1) = "New Textnode Value" myNode.Rewrite End Sub
So I guess maybe your myWS.Cells(FileRow, 4) 's type is not a string. Trying
myNode.TextLine(1) = CStr(myWS.Cells(FileRow, 4))
HTH,
Yongan
No, unfortunately it don't work, the error is now at line
myNode.TextLine(1) = s
"BAD ELEMENT"
Roberto Cano said:
myNode.TextLine(1): A myWS.Cells(FileRow, 4): NODO111
But the error is the same
TextNodeElements seem to be troublesome in VBA. Gary Manuel had a similar problem with Text Nodes.
Does it make any difference if you copy the text to a new variable before assignment?
Dim s As String s = myWS.Cells(FileRow, 4) myNode.TextLine(1) = s
Yes, it works, it show me
But the error is the same, in the line
myNode.TextLine(1) = myWS.Cells(FileRow, 4) 'Store new Textnode Value
Is really important for my my program update node text, How can I avoid this error?
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)
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"
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