Barts
Barts

Reputation: 3

Powerpoint VBA change picture on layout after theme change

I have a Powerpoint template, picture on Title Slide layout. User can open a custom Userform to change the picture (VBA deletes old pic, then inserts pic-of-choice).

But after the theme was changed by user, subsequent picture changes are not visible. This is as far as I can see because the picture is changed only in the title slide layout of the original theme. Changing the theme actually adds a new slide master.

Is there a way to change the picture on the Title Slide layout on each slide master in my presentation?

Here's the VBA code:

    Set shp = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes(strShapeName)

    With shp
      sngTop = .Top
      sngLeft = .Left
      sngWidth = .Width
      sngHeight = .Height
      .Delete
    End With

    Set shp = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes.AddPicture _
      (strFullFileName, msoFalse, msoTrue, _
      sngLeft, sngTop, sngWidth, sngHeight)

    With shp
      .ZOrder msoSendToBack
      .Name = strShapeName
    End With

Thanks for any suggestion.

Upvotes: 0

Views: 727

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

Try something like this:

Dim oDes As Design
Dim shp As Shape

For Each oDes In ActivePresentation.Designs
    Set shp = oDes.SlideMaster.CustomLayouts(1).Shapes(strShapeName)

    With shp
      sngTop = .Top
      sngLeft = .Left
      sngWidth = .Width
      sngHeight = .Height
      .Delete
    End With

    Set shp = oDes.SlideMaster.CustomLayouts(1).Shapes.AddPicture _
      (strFullFileName, msoFalse, msoTrue, _
      sngLeft, sngTop, sngWidth, sngHeight)

    With shp
      .ZOrder msoSendToBack
      .Name = strShapeName
    End With

    Next    ' Design

Upvotes: 1

Related Questions