I’m trying to write a vba macro for powerpoint that imports images from a folder onto a slide. That part is easy. I’ve found that if I re-run the macro it adds the pictures each time (i.e. if I run the macro 4 times there will be 4 of the same picture). This is a macro that I need to be able to run a few times.
I’d like to add a line that deletes the pictures if they’re already there before adding again, but .Delete only works if you know the specific image name (i.e. “picture 2”). Every time the images are imported by the macro however they are given some random number. Is there any way to control the number of the picture when importing it (i.e. assign “picture 1”)? Or does anyone have some other suggestion for how to avoid repeatedly adding the same images?
Set plot1 = .Shapes.AddPicture(imagePath & “image.png”, LinkToFile = False, SaveWithDocument = True, Left:=100, Top:=100, Width:=180, Height:=160)
Elizabeth Michiko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.