dim strDwgName As String
dim strFind As String
dim strReplace As String
Dim ent As AcadEntity
For Each ent In Thisdrawing.ModelSpace
If TypeOf ent Is AcadText Or TypeOf ent Is AcadMText Then
With ent
If InStr(.TextString, strFind) Then .TextString = ReplaceStr(.TextString, strFind, strReplace, False)
End With
End If
Next ent
補充:妳那個不能改的標題欄可能是插入的屬性塊,是屬性塊裏面的屬性的文字,這個不能進入塊中修改,只能在對象中。
strFind = "耳板"
Dim objBlkRef As AcadBlockReference
Dim varAttributes '取得塊屬性,顯示屬性標簽和值
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AcadBlockReference Then
Set objBlkRef = ent
varAttributes = objBlkRef.GetAttributes
If UBound(varAttributes) Then
For i = 0 To UBound(varAttributes)
If varAttributes(i).TextString = strFind Then
varAttributes(i).TextString = "strFind"
End If
Next i
End If
End If
Next ent
這樣可以替換塊中的文字