Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I detect pictures on a worksheet in MS Excel?

Status
Not open for further replies.

JensKKK

Technical User
May 8, 2007
119
GB
Here is the situation. I am creating a report function in MS Excel. I am writing text and into a MS Excel sheet and I paste graphs into the sheet as well. This works all fine when using it once.

Next time I run the routine I want to delete the previous report. It is easy to delete all text by using

Sheets("detailed results").Select
Sheets("detailed results").Cells(5, 2).Resize(15000, 9).Select
With Selection.Font
.Name = "Arial"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Font.Bold = False
Selection.ClearContents

However picture that I previously pasted into the report are still there. How can I detect and then delete pictures?

Any ideas welcome.

Thanks for your help in advance.
 
For each shp in sheets("Sheetname").shapes
shp.delete
next


This will delete all charts, textboxes and shapes

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 



Hi,

On each Sheet Object there is a Shapes Collection. You can loop thru that collection to find stuff
Code:
dim shp as shape
for each shp in activesheet.shapes
  msgbox shp.name
next
Use the Watch Window to discover other properties of an Object that may be hlpfup like TYPE.

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top