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中文網其他相關文章!