×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Delete Block in 2004 VBA

Delete Block in 2004 VBA

Delete Block in 2004 VBA

(OP)
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?

RE: Delete Block in 2004 VBA

(OP)
Thank you

RE: Delete Block in 2004 VBA

(OP)
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.

RE: Delete Block in 2004 VBA

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources