Updating textstring Property

The VBA forum deals with IntelliCAD 2000 VBA (Visual Basic for Applications) issues.

Moderator: CMS Inc

Post Reply
Accuright
Valued Contributor
Posts: 47
Joined: Thu Jul 26, 2012 2:19 pm

Updating textstring Property

Post by Accuright » Thu Sep 27, 2012 12:45 pm

Hello,

I'm writing VBA for IntelliCAD 7.2 and have run into an interesting roadblock. I have been trying to update the textstring property of a selected entity with failure. When changing the textstring property of an entity, the code invokes an automation error. Upon adding an 'On Error Resume Next' handler, I discovered that while the first execution of the code results in the automation error, if the code is executed again on the same selection then it will work perfectly, updating the text in the ModelSpace to what is entered. Selecting a new entity to edit invokes the error, but again works the second, third, and forthcoming times that particular entity is selected. Below is the code, which I isolated to a single userform in a clean CommonProjects file for my tests:

Code: Select all

Private Sub UpdTxtBtn_Click()
    Dim PickObj As Object
    Dim Txt As String
    Dim Pt1 As IntelliCAD.Point
    
    Me.Hide

    ThisWorkspace.Application.ActiveDocument.Utility.GetEntity PickObj, Pt1, "Please select text in Model Space..."
    
    Txt = InputBox("Enter the text you wish to edit the selected text to...", "New Text", "Sample Edit")
    
    On Error Resume Next
    PickObj.TextString = Txt
    PickObj.Update
    
    Err.Clear
    
    Me.Show
    
End Sub
Any idea what could be causing the initial automation error?
Post Reply