Option Explicit
'*********** DECLARE VARIABLES *****************
Dim entX As AcadObject 'Entity object..
Dim attribZ As Variant 'Attributes..
Dim countX As Integer 'Counter..
Dim blnAttributes As Boolean 'Has Attributes?..
Dim areaX As Double 'Area value for entity..
'*********** DECLARE VARIABLES *****************
Sub Attribute_values()
' Start loop to access attributes..
For Each entX In ThisDrawing.ModelSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
If entX.HasAttributes Then 'Check if object has attributes..
blnAttributes = True ' True if yes..
Exit For
' If no attributes found....
ElseIf Not blnAttributes Then
MsgBox "No attributes found for this block in the drawing..", vbInformation
'GoTo Finished
End If
End If
Next
' Start main loop to get attribute values for the attributes..
For Each entX In ThisDrawing.ModelSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
attribZ = entX.GetAttributes
For countX = LBound(attribZ) To UBound(attribZ)
Select Case attribZ(countX).TagString 'The name of the attitrubute tag..
Case "AREA"
areaX = attribZ(countX).TextString
End Select
Next countX
End If 'End main if statement..
Next entX
' Start main loop to update attribute values for the attributes..
For Each entX In ThisDrawing.ModelSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
attribZ = entX.GetAttributes
For countX = LBound(attribZ) To UBound(attribZ)
Select Case attribZ(countX).TagString 'The name of the attitrubute tag..
Case "AREA"
attribZ(countX).TextString = Textbox1.Text 'For example, textbox1 is on a userform..
End Select
Next countX
End If 'End main if statement..
Next entX
Finished:
End Sub