SwapnilB10
Mechanical
Hello everyone,
can anyone help me with creating a macro to update all the text available in view with suffix or prefix using an input box?
for ex. if I have text 1, 2 & n etc available in any view the macro should update it with H1, H2 & Hn respectively when user provide "H" in input field.
I have a below code which replaces all text boxes having text "1" with "H1" but this is limited to text having 1 in it.
i want to have it for all the text boxes with 2, 3 or 5 etc.
can anyone help me with creating a macro to update all the text available in view with suffix or prefix using an input box?
for ex. if I have text 1, 2 & n etc available in any view the macro should update it with H1, H2 & Hn respectively when user provide "H" in input field.
I have a below code which replaces all text boxes having text "1" with "H1" but this is limited to text having 1 in it.
i want to have it for all the text boxes with 2, 3 or 5 etc.
Code:
Sub Catmain()
n = 0
Set oDoc = CATIA.ActiveDocument
Set oSheets = oDoc.Sheets
Set oViews = oSheets.ActiveSheet.Views
Set oView = oViews.ActiveView
Set oTexts = oView.Texts
txt_to_src = "1"
txt_to_place = "H" & txt_to_src
For Each srcText In oTexts
If srcText.Text = txt_to_src Then
srcText.Text = txt_to_place
n = n + 1
End If
Next
MsgBox n & " texts have been replaced"
End Sub