Consulting

Results 1 to 3 of 3

Thread: Change Image in an Image Placeholder

  1. #1

    Change Image in an Image Placeholder

    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!

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    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!

Tags for this Thread

Posting Permissions

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