Delete pic's and logos

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247
Hi

I have some pictures/logos at a spreadsheet, and I want to delete them. I recorded the following macro but when I run the macro it gives me an error it points to the third line of the code, can any one tell me what I'm doing wrong?

Sub mhiDeletePic()
'
' mhiDeletePic Macro
' Macro recorded 12/1/2005 by CONMHI
'

'
Sheets("Staffing Summary").Select
Cells.Select
ActiveSheet.Shapes("Picture 1").Select
Selection.delete
End Sub
 
Its our company logo. Its just that it is positioned in cell A1 area not in cell A1 to be exact, and I want to put in "Back to summary" button in that area.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Did you try my earlier suggestion?<ul>[*]If yes, then at the risk of redundancy, what msoShapeType is your logo? Or is it not part of the shapes collection at all?[*]If not, then please explain what aspects of your situation led you to determine that this line of problem solving will not yield helpful results.[/list]
 
Upvote 0
Then look up the enumeration group msoShapeType in the object browser in the VBE and add edit your IF statement to look for that too (assuming only your logo is of the type you want to delete and that your logo is, indeed, a shape residing on the WS's drawing layer).

I'm a bit lost here, I don't know what is enumeration group? msoshapeType? In the object browser I see 100's of item listed and under shapes there are more.....hmm
 
Upvote 0
OK - your object browser should be showing a couple of windows, one for classes and another for members. Type "msoshapetype" into the search textbox control and click the find button (the binoculars). You should see Library=Office, Class=MsoShapeType as one of the results. Click on that and your classes should jump to MsoShapeType. To the left are two little yellowish squares. That icon tells you that this is a class of enumerated constants. Click on the first member in the member pane and at the bottom you'll see something like

Const msoAutoShape = 1
Member of Office∙MsoShapeType

which tells you that a "1" is an AutoShape. Click on msoPicture and you'll see that pictures are "13". A diagram for example, would return a .Type of 21.

If you ran the code I posted, your Immediate Window should contain a listing of shapes' names and type constants. Locate your logo's data and check the members to see what type constant was returned. And were there any other shapes that you do not want to delete that returned the same constant?
 
Upvote 0
highndry
Did you try the macro I supplied? It works like a charm for me. It deletes all the pictures and shapes, circles, squares etc, for me.
John
 
Upvote 0


It says no items found. I'm trying to paste the print screen but it doesn't work.

@jolivanes: Your code runs fine and so does greg's but it doesn't delete my pic. [/code]
 
Upvote 0
Would appreciate any help on this.


Sheets("Staffing Summary").Select
Cells.Select
ActiveSheet.Shapes("Picture 14").Select
Selection.delete

instead of deleting picture 14, how can I delete Pinture 1 thru Picture infinity, or in other words all pictures.

Thanks
 
Upvote 0
Is there a wild card in Visual Basic, for example can I use an "Picture *" instead of "Picture 14"

Sheets("Staffing Summary").Select
Cells.Select
ActiveSheet.Shapes("Picture 14").Select
Selection.delete


Thanks
 
Upvote 0
Do you just want to end up with the data on the worksheet?

If so why not just copy only the data to a new worksheet/workbook?
 
Upvote 0
Do you just want to end up with the data on the worksheet?

If so why not just copy only the data to a new worksheet/workbook?

That is the problem, I'm copying the data (Tab) from a SAP run report, and the SAP programmers put our company's logo in the worksheet. So when I copy the worksheet/s it copys the logo as well. I don't want to manually delete it....
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,109
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top