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 '已选择的
'sSet.Select acSelectionSetAll, , , tj1, tj2 '选择全部
For Each eV In sSet '在选择集中进行循环
If InStr(eV.TextString, "J") > 0 Then eV.color = acRed
Next
sSet.Update
sSet.Delete
End Sub
1.首先请到网上下个VBA timer 控件并把里面的“.ocx”文件放到C盘-windows-system32文件夹下,然后开始-运行-“regsvr32 VBAtimer.ocx”-确定(注:这里假设你下的的OCX文件名为“VBAtimer.ocx”)。
2.然后打开excel,按照你自己的要建立窗体,然后在工具栏上点右键-“附加控件”-找到刚刚装的VBAtimer控件然后在窗体任意地方画一个timer控件。
3.然后在新建的窗体上右键-“查看代码”,并输入以下代码:
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.最后在在工程管理窗口上双击Thisworkbook,在弹出的代码框输入以下代码:
Private Sub Workbook_Open()
UserForm1.Show
End Sub
5.附:如果2、3、4步不知道做的话,做完第一步然后把邮箱留给我。
以上是VBA将关键字J应用于多个CAD文字的颜色批量修改的详细内容。更多信息请关注PHP中文网其他相关文章!