Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Block in 2004 VBA

Status
Not open for further replies.

CanonShooter

Structural
Joined
Oct 14, 2005
Messages
39
Location
US
I am using AutoCAD 2004, and trying to delete a block in VBA.

I get an error that the block or object is referenced. In looking thru the help files, I noticed that the Blocks Collection does not have a delete function. But I don't want to delete the whole collection, just a block. Basically, what I tried is:

Dim ABCBlock As AcadBlock
Set ABCBlock = ThisDrawing.Blocks.Item("Canon_Block")
ABCBlock .Delete

I know the block is there. Purge will delete it, but I guess I am just having a mental block on deleting it with code. Any ideas?
 
The only problem I still have is that the code you referenced assumes you just picked the entity (I guess). I do not want to pick it. I am currently looking in the Blocks collection, and if it is in there, delete it.

Apparently I need to somehow get the actual object from the AcadBlockReference "collection" (if it is there), and I don't know how to do that.
 
Nevermind. I am working now.

Since I know the name, and am working with only one block, I just kill it like the code says (DeleteRefs part).

I'm good, and thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top