user3070849
user3070849

Reputation: 41

Auto Update every picture in a PowerPoint Slideshow

I have a very large and complex PowerPoint with a full size image as the background for every individual slide. I have a directory full of these background pictures, which are all JPEG's. Sometimes I change these photographs, which are made with Photoshop, and when I change them, I save them over the original JPEG in the same directory.

I then have to update them in the PowerPoint. The manual functios to do this is to right-click the photograph, and click replace photo, then pick the new JPEG from the file menu. I want to write a macro in Visual Basic that will go through the entire slideshow, and reload the graphic from the updated JPEGs, without me having to do it manually. I don't know if it is possible, because I don't know if PowerPoint actually remembers the path and filename of each picture that it places.

Is there a picture property which contains the path and filename that was used to paste the picture in the first place? If there is, I could find that property, query it, and use that as the path to reload and thereby update the picture recursively all the way through slide by slide.

Would this be possible?

Upvotes: 2

Views: 3716

Answers (1)

David Zemens
David Zemens

Reputation: 53623

Is there a picture property which contains the path and filename that was used to paste the picture in the first place?

Not that I'm aware of, but you can create your own, using the Tags property:

http://msdn.microsoft.com/en-us/library/office/ff744290(v=office.15).aspx

You will have to assign a custom tag for each slide, like:

Sub AssignTag()
    Dim sld as Slide
    Set sld = ActivePresentation.Slides(1)
    sld.Tags.Add "img_location", "C:\files\image1.JPG"

End Sub

Once the slide's Tags have been configured, then you can do something like this to update from that location:

Sub UpdateJPGs()
    Dim sld As Slide
    Dim path As String

    For Each sld In ActivePresentation.Slides
        path = sld.Tags("img_location")
        If Not path = vbNullString Then
            On Error Resume Next
            sld.Background.Fill.UserPicture path
            If Err Then
                MsgBox "Unable to update slide #" & sld.SlideNumber
                Err.Clear
            End If
            On Error GoTo 0
        End If
    Next
End Sub

Upvotes: 1

Related Questions