+ Reply to Thread
Results 1 to 8 of 8

Deleting an image

  1. #1
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144

    Deleting an image

    I have created a macro that inserts some data and a drawing into a template and then saves it with a new name.

    But I am having a problem deleting the old drawing.

    Could the problem be that my drawing is a "shape" ?
    Or not really in the cell M1 as I intended?
    Or could I give the drawing a name when I insert it, then delete it by name next time around?

    Unfortunately my workbook is 150k so I cant upload it here, but I could email it to anyone who is interested.

    My code looks like this:

    Please Login or Register  to view this content.
    Last edited by treva26; 07-17-2007 at 04:17 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello treva26,

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144
    No thats not working.
    I have other pictures on the worksheet that I dont want to delete.

    The one I do want to delete is (or should be) in M1.
    Its the one I insert later in the macro, can I set its name or label when I insert it? Then delete it by name later?

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144
    I have managed to get a small enough version to post on here:
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    In your code you don't actually give it a name that I can see as Drawing1 is a variable that is not set.

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    The picture will then have a name.

    You can then delete it with

    Please Login or Register  to view this content.

    rylo

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello treva26,

    Copy and paste this macro into Module 2.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Shapes are not in cells.
    Please Login or Register  to view this content.
    will not delete any shapes.

    A shape does have a .TopLeftCell which is one way to see where it is.
    This will look at all shapes on sheet 1 and delete any of them whose TopLeft is M1.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144
    Oh wow, 3 different ways to do it!
    Thanks guys
    Last edited by treva26; 07-18-2007 at 07:56 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1