當前位置:成語大全網 - 成語詞典 - 我想在CAD中做到批量修改文字,比如我有壹組文字 1 2 3 4 我要批量修改成 A B C D 最好通過CAD中的VBA實現

我想在CAD中做到批量修改文字,比如我有壹組文字 1 2 3 4 我要批量修改成 A B C D 最好通過CAD中的VBA實現

Sub 替換()

Dim aa As String

Dim bb As String

aa = "我的中國心"

bb = "長江,黃河"

Dim myselection As AcadSelectionSet

For Each myselection In ThisDrawing.selectionSets

If myselection.Name = "qqq" Then

myselection.Delete

Exit For

End If

Next

Set myselection = ThisDrawing.selectionSets.Add("qqq")

myselection.SelectOnScreen

Dim mytext As AcadMText

Dim myentity As AcadEntity

For Each myentity In myselection

If myentity.ObjectName = "AcDbMText" Then

Set mytext = myentity

If mytext.TextString = aa Then

mytext.TextString = bb

End If

A = A + 1

End If

Next

MsgBox A

End Sub