Powerpoint 2010 VBA: Detect changes to slide layout RRS feed

  • Question

  • Is it possible to detect additions / changes to the base layout of a slide?

    For example, if we have a slide with the "Two content layout", then there should be three text frames on the slide - the title, and the two content frames. Given that, would it be possible to detect if a fourth text frame had been added to the slide as well?

    I'm guessing that there would be an additional object in the Shapes collection, but would there be any way of determining which of the objects in the collection was the new arrival?]


    Thanks in advance.

    Wednesday, August 3, 2011 1:40 PM

All replies

  • To an extent! But it is not always fool-proof

    You can loop through the slides and get the shapes.count

    and then iterate the count and check for the names

    Ideally, the code will give the following for a Two content slide

    Content Placeholder n
    Content Placeholder m
    Title x


    Sunday, August 7, 2011 6:55 AM
  • If you can assume that all original slides would be stock PPT layouts w/ no add'l shapes added, then Shasur's solution would work fine.

    If the original slides might have other shapes on them than the ones provided by the layout, you'd need to record that fact somehow first, so you have a basis for comparison later.

    A tag applied to the slide that lists all of the names of the original shapes would be one approach.

    Or perhaps simpler, tag each original shape on the slide:

    Dim oSh as Shape

    Dim oSl as Slide

    For each osl in activepresentation.slides

    For each oSh in oSl.Shapes

    Osh.Tags.Add "Original", "YES"



    Then when you want to test a slide for changes:

    For Each oSh in oSl.Shapes

    If Len(oSh.Tags("Original")) > 0 Then

    MsgBox "I'm original"


    MsgBox "Somebody added me"

    End If


    Steve Rindsberg PowerPoint MVP since before dirt
    • Proposed as answer by Shasur Sunday, August 14, 2011 8:44 AM
    Friday, August 12, 2011 4:04 PM
  • But you'd still need to tag shapes on the slides when the presentation was created, rather than being able to identify the shapes that are created from a blank instance of the layout?
    Wednesday, August 17, 2011 11:05 AM