VBA applies keyword J to batch modify the colors of multiple CAD texts

WBOY
Release: 2024-01-15 15:51:35
forward
608 people have browsed it

用vba批量修改多个cad文字颜色每个cad文字搜索关键字 J

Use vba to batch modify multiple cad text colors and search keywords for each cad text J hh4232

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

Color transformation in VBA programming

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!

source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template