PDA

View Full Version : Change Image in an Image Placeholder



hunter21188
12-04-2015, 11:29 AM
Hey y'all,

I have an image placeholder in a slide, and I am trying to change this image based on what is selected by the user. This is what I have currently, but it is not working:


Private Sub MainImage()


If ComboBox2 = "Second Image" Then
ActiveWindow.Selection.SlideRange.Shapes("MainImage").Fill.UserPicture ("J:\image.png")

End If

End Sub


This code works fine if I use an actual shape as a placeholder, so I assume the ".Shape()" part may be wrong? Any help is greatly appreciated!

Thanks!

John Wilson
12-05-2015, 06:56 AM
Code like that should change the image in a picture placeholder (assuming names / paths are correct) BUT it will not act as a picture placeholder and images may distort rather than be cropped. If you need to do this and retain those features there is no simple way AFAIK. You could maybe insert the image onto a blank slide, cut it, select the placeholder and paste into it using
ActiveWindow.View.Paste but I don't know of any direct way.

hunter21188
12-05-2015, 02:08 PM
Hmm, not sure why that wasn't working, but I was able to get it to do what I wanted using a shape placeholder. Thanks!