Solved

Excel - Remove shapes

Posted on 2000-03-15
4
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Outlook Free & Paid Tools
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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