Hi,
how can I insert text into AutoCAD block attribute using VBA? I have the list of items in Excel with coordinates.
The macro is in Excel.
The blocks are placed but without text inside. I would appreciate for support. RK
Solved! Go to Solution.
Solved by MakCADD. Go to Solution.
easiest way is to export attribute values to csv file (attout) and open in excel and replace the data with new value and import (attin) file again in the drawing
vba
attribute=block.getattributes
attribute(index).textstring=newvalue
Thank you MakCADD for the answer.
It should be done by VBA (part of solution) why I try to implement nothing changed. The attribute inside block (item name) stay empty.
Could you send me any example?
It would help if you showed the code you have so far. You also need to know the tag name of the attribute you want to change if there's more than one attribute in the block reference.
For each object in thisdrawing.layouts(layout.name).block
If typeof object is acadblockreference then
Set blockref=object
If blockref.name= "ABCD" then
Attr=blockref.getattributes
For I=0 to ubound(attr)
If attr(I).tagstring="aaaa" then attr(I).textstring="zzzz"
Next I
End if
End if
Next object
Moderator edit: Put code into code window using </> button.