Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-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
Oct 14, 2005
39
0
0
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?
 
Replies continue below

Recommended for you

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.
Back
Top