Home > Article > Software Tutorial > VBA applies keyword J to batch modify the colors of multiple CAD texts
Sub txtGSssssssssssss()
'On Error Resume Next
Dim sSet As AcadSelectionSet, eV As AcadText, i
Dim tj1() As Integer, tj2() As Variant
ReDim tj1(0), tj2(0): tj1(0) = 0: tj2(0) = "Text"
Set sSet = ThisDrawing.SelectionSets.Add("pl1")
sSet.Select acSelectionSetPrevious, , , tj1, tj2 'Selected
'sSet.Select acSelectionSetAll, , , tj1, tj2 'Select all
For Each eV In sSet 'Loop in the selection set
If InStr(eV.TextString, "J") > 0 Then eV.color = acRed
Next
sSet.Update
sSet.Delete
End Sub
1. First, please download the VBA timer control online and put the ".ocx" file in it to the C drive-windows-system32 folder, then start-run-"regsvr32 VBAtimer.ocx"-OK (note : It is assumed here that the OCX file you download is named "VBAtimer.ocx").
2. Then open excel, create a form according to your own needs, then right-click on the toolbar - "Additional Controls" - find the VBAtimer control you just installed and draw a timer control anywhere on the form.
3. Then right-click on the newly created form - "View Code" and enter the following code:
Private Sub CommandButton1_Click()
UserForm1.Label1.Font.Bold = True
UserForm1.Label1.Font.Italic = True
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Sub timer1_timer()
Dim a As Long, b As Long, c As Long
Randomize
a = Int(256 * Rnd )
b = Int(256 * Rnd )
c = Int(256 * Rnd )
UserForm1.Label1.ForeColor = RGB(a, b, c)
End Sub
Private Sub CommandButton2_Click()
UserForm1.Label1.Font.Bold = False
UserForm1.Label1.Font.Italic = False
Timer1.Enabled = False
End Sub
4. Finally, double-click Thisworkbook on the project management window and enter the following code in the pop-up code box:
Private Sub Workbook_Open()
UserForm1.Show
End Sub
5. Attachment: If you don’t know how to do steps 2, 3, and 4, complete the first step and leave your email address with me.
The above is the detailed content of VBA applies keyword J to batch modify the colors of multiple CAD texts. For more information, please follow other related articles on the PHP Chinese website!