Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting text selection to uppercase

Status
Not open for further replies.

LucasC

Automotive
Feb 18, 2019
157
0
0
US
Can someone point out what I've done wrong? The intent is to simply select a textbox and change all lowercase characters to uppercase.

Code:
Private Sub CommandButton41_Click()
On Error Resume Next
If InStr(CATIA.ActiveDocument.Name, ".CATDrawing") < 1 Then
MsgBox "Active file is not a CATDrawing!"
Exit Sub
If Error.Number <> 0 Then
Err.Clear
End If
End If

Dim DrawingDocument1 As Document
Set DrawingDocument1 = CATIA.ActiveDocument

Set Selection2 = DrawingDocument1.selection

Selection2.Text = UCase(Selection2.Text)

DrawingDocument1.selection.Clear
End Sub
 
Replies continue below

Recommended for you

Code:
Sub CATMain()
    Dim oSel As Selection
    Set oSel = CATIA.ActiveDocument.Selection

    For i = 1 To oSel.Count
        Dim selItem As Object
        Set selItem = oSel.Item(i).Value
        
        If TypeName(selItem) = "DrawingText" Then
            selItem.Text = UCase(selItem.Text)
        End If
        
    Next
End Sub
 
Status
Not open for further replies.
Back
Top