Change value of TextBox.Text

Change value of TextBox.Text

mr_ensing
Advocate Advocate
1,026 Views
2 Replies
Message 1 of 3

Change value of TextBox.Text

mr_ensing
Advocate
Advocate

The situation: Drawing --> Sheet --> View -->  Sketch --> TextBoxes

These TextBoxes need changing, on several drawings. Not that complicated, it seems.

 

But the line that does the actual work (oTextbox.Text = "TEST") refuses to work. The TextBox.Text property is read/write, so what's the problem?

 

TextBoxes.png

 

 

 

Private Sub ChangeTextboxText()
    'drawing
    Dim idwDoc As DrawingDocument
    Set idwDoc = ThisApplication.ActiveDocument
    
    'active sheet
    Dim oSheet As sheet
    Set oSheet = idwDoc.ActiveSheet
    
    'loop views
    Dim oView As DrawingView
    For Each oView In oSheet.DrawingViews
        
        'loop sketches
        Dim oSketch As sketch
        For Each oSketch In oView.Sketches
            
            'loop textboxes
            Dim oTextbox As TextBox
            For Each oTextbox In oSketch.TextBoxes
                
                'change text
                oTextbox.Text = "TEST"
                
            Next oTextbox

        Next oSketch
    
    Next oView
    
End Sub

 

 

0 Likes
Accepted solutions (1)
1,027 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @mr_ensing 

You'll have to edit the sketch in order to change the text 🙂

For Each oSketch In oView.Sketches
            
            'loop textboxes
            Dim oTextbox As Inventor.TextBox
            For Each oTextbox In oSketch.TextBoxes
                'change text
				oSketch.Edit
                oTextbox.Text = "Test"
                oSketch.ExitEdit
            Next oTextbox

        Next oSketch
0 Likes
Message 3 of 3

mr_ensing
Advocate
Advocate

That's it! Thanks a bunch.