Solved

Excel - Remove shapes

Posted on 2000-03-15
4
595 Views
Last Modified: 2008-03-17
I have added shapes to my worksheet from VBA using the following code:

With tasksheet.Shapes

With .AddShape(msoShapeRectangle, tlh1, tlh2, brh1, brh2)

With .Fill
     .ForeColor.RGB = RGB(200, 200, 200)
     .BackColor.RGB = RGB(200, 200, 200)
     .Patterned msoPattern50Percent
End With

End With

End With

This appears to work well, but I need to be able to remove all the shapes on the worksheet using a button_click().

I have also placed textboxes using addtextbox(etc..) so I must remove these at the same time.

hope someone can help.
Thanks

/Bob
0
Comment
Question by:BobR
  • 2
4 Comments
 
LVL 5

Expert Comment

by:vboukhar
ID: 2619125
You can use something like that:
for each c in activesheet.shapes
 c.delete
next
It removes texboxes too
0
 
LVL 9

Expert Comment

by:antrat
ID: 2619126
Hi BobR

This one line should do it


ActiveSheet.DrawingObjects.Delete

good luck


antrat


0
 

Author Comment

by:BobR
ID: 2627486
Thanks for the solutions, but I ommitted one item.
On the worksheet are several buttons and both your solutions remove them as well, can you change the solution to leave these buttons on the worksheet.
Sorry for the ommission.
/Bob
0
 
LVL 5

Accepted Solution

by:
vboukhar earned 100 total points
ID: 2627511
Try this one:
For Each c In ActiveSheet.Shapes
 If c.Type <> msoOLEControlObject Then
  c.Delete
 End If
Next

Good luck!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question