成语大全网 - 成语词典 - 我想在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