VBA to Delete Picture fro Sheet

  • Hi,


    I have a payment receipt template that inserts a picture of a stamp "Paid in Full" when a payment is applied.


    I recorded a Macro to delete that picture, but every time the code inserts the picture it gives it a new name (Picture 48, next time the picture is inserted it is Picture 49....).


    How can this code be modified to delete the picture no mater what the name is? The original picture name is "paid_in_full-stamp.png".


    Here are both of my codes...


  • Re: VBA to Delete Picture fro Sheet


    You can use the ordinal number of the shape to delete it.


    If there's only the 1 picture/shape:

    Code
    activesheet.shapes(1).delete


    If more than 1 picture and the 'Paid' pic is the last one added:

    Code
    activesheet.shapes(activesheet.shapes.count).delete




    You could always name the shape when you add it and then use the name instead of the ordinal number in the first example, but simplest ideas first...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!