Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Objects in spreadsheet not selected by recorded macro. (https://www.askmehelpdesk.com/showthread.php?t=350326)

  • May 5, 2009, 11:49 PM
    rsdjimbie
    Objects in spreadsheet not selected by recorded macro.
    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!
  • May 6, 2009, 09:08 AM
    JBeaucaire

    So, post up a smaller sample of your sheet with your macro in it, I'll take a look at it.
  • May 6, 2009, 10:47 AM
    JBeaucaire

    Or... try this short macro on for size:
    Code:

    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

  • May 6, 2009, 11:41 AM
    rsdjimbie
    1 Attachment(s)
    A small example. No macro added as it shows very little. Thank you.
  • May 6, 2009, 01:18 PM
    JBeaucaire

    Did you try the macro above, yet?
  • May 6, 2009, 01:21 PM
    JBeaucaire
    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:
    Code:

    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

  • May 7, 2009, 12:47 AM
    rsdjimbie

    Most imprsesive!
    Thanks JB.
  • Jan 25, 2011, 05:47 AM
    rsdjimbie
    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.
  • Jan 25, 2011, 07:42 AM
    JBeaucaire

    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?
  • Jan 25, 2011, 10:50 PM
    rsdjimbie
    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.
  • Jan 25, 2011, 11:10 PM
    rsdjimbie
    Where is the attachment icon!
  • Jan 26, 2011, 04:10 AM
    JBeaucaire

    You'll have to use the GO ADVANCED icon first.
  • Jan 26, 2011, 10:56 PM
    rsdjimbie
    Do not have a advance icon either!
    Anyhow, I have used Special-Objects and then "Objects.Delete", works well.
    Code:

    ActiveSheet.DrawingObjects.Select
        ActiveSheet.DrawingObjects.Delete

    Still can not see the advanced icon. Weird.

  • All times are GMT -7. The time now is 06:07 PM.