Solved

Excel - Remove shapes

Posted on 2000-03-15
4
598 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

734 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