View Full Version : Objects in spreadsheet not selected by recorded macro.
rsdjimbie
May 5, 2009, 11:49 PM
I have a wage bill with 500 or so employees on it.
To simplify things, did I add a small photo of each worker next to his details.
With so many photos on the sheet is it quite large for emailing, and therfore did I record a macro to select and deleat all the photos.
Once the macro is run, does it do so without any error massages, and I can see the screen updating, but all the photos are still there!
JBeaucaire
May 6, 2009, 09:08 AM
So, post up a smaller sample of your sheet with your macro in it, I'll take a look at it.
JBeaucaire
May 6, 2009, 10:47 AM
Or... try this short macro on for size:
Sub DeleteAllPictures()
Dim DrObj, Pic
Set DrObj = ActiveSheet.DrawingObjects
For Each Pic In DrObj
If Left(Pic.Name, 7) = "Picture" Then Pic.Delete
Next
End Sub
rsdjimbie
May 6, 2009, 11:41 AM
A small example. No macro added as it shows very little. Thank you.
JBeaucaire
May 6, 2009, 01:18 PM
Did you try the macro above, yet?
JBeaucaire
May 6, 2009, 01:21 PM
You know, always start with the workbook, I say, people always leave out key details like "My workbook is protected".
Hehe, here, one line of code added to make it runnable on a locked sheet:
Sub DeleteAllPictures()
Dim DrObj, Pic
Set DrObj = ActiveSheet.DrawingObjects
ActiveSheet.Protect UserInterfaceOnly:=True
For Each Pic In DrObj
If Left(Pic.Name, 7) = "Picture" Then Pic.Delete
Next
End Sub
rsdjimbie
May 7, 2009, 12:47 AM
Most imprsesive!
Thanks JB.
rsdjimbie
Jan 25, 2011, 05:47 AM
Now out of the blue is the macro giving me the following error message:"Run time error 1004
Unable to get the Name property of the picture class."
Do you have any idea, because I have been looking and cannot find the cause.
Sheet is not protcted.
Thanks.
JBeaucaire
Jan 25, 2011, 07:42 AM
So what's different? Are you still using Excel 2003? Can you post an example of the misbehaving workbook with you current macro in it?
rsdjimbie
Jan 25, 2011, 10:50 PM
Moved up to Excel 2007 some time back, but did not have any problem until now. Post to follow, very difficult to get the file to fit the max allowable bites.
rsdjimbie
Jan 25, 2011, 11:10 PM
Where is the attachment icon!
JBeaucaire
Jan 26, 2011, 04:10 AM
You'll have to use the GO ADVANCED icon first.
rsdjimbie
Jan 26, 2011, 10:56 PM
Do not have a advance icon either!
Anyhow, I have used Special-Objects and then "Objects.Delete", works well.
ActiveSheet.DrawingObjects.Select
ActiveSheet.DrawingObjects.Delete
Still can not see the advanced icon. Weird.