〔求助〕vba中我想构造要一个改物体属性的函数
Public Sub ChangeAtt(ent As object, Att As String, value As Variant)With ent
.Att = value
End With
End Sub
其中ent表示实体,att是这个实体的一个属性,value是值
上面的程序运行到.Att = value时会出错,不知道有没有办法解决?
或者vba有自带的类似的函数? ' 函数
Sub SetAttValue(AttEnt As AcadBlockReference, Tag As String, Value As String)
Dim Att As AcadAttributeReference
If AttEnt.HasAttributes = True Then
Dim AttVal As Variant
AttVal = AttEnt.GetAttributes
Dim i As Integer
For i = 0 To UBound(AttVal)
If AttVal(i).TagString = Tag Then
AttVal(i).TextString = Value
End If
Next i
End If
End Sub
' 例子
Sub mjtd()
Dim ent As AcadEntity
Dim pnt As Variant
ThisDrawing.Utility.GetEntity ent, pnt, "Get Block:"
SetAttValue ent, "CLBJ", "mjtd.com"
End Sub
页:
[1]