Find the slidelayout in PowerPoint

124 views Asked by At

I am trying to figure out if a specific custom layout is in my presentation. I want to use this to create a slide with a TOC that lists the slides with this specific layout.

After some searching and trying I got this far, but it aborts on the below bold item, any suggestions :

Sub ShowSlideLayouts()

  Dim oSlide As Slide
  Dim idSlide As String
  Dim oLayoutName As String
  Dim sFileName As String
  Dim iFileNum As String

  sFileName = "C:\temp\PowerPointLayouts.TXT"

  iFileNum = FreeFile()
  Open sFileName For Output As iFileNum

  For Each oSlide In ActivePresentation.Slides
    idSlide = ActivePresentation.Slides.***SlideID*** <-- wrong method/member

    'Print #iFileNum, oSlide.Layout
    Print #iFileNum, ActivePresentation.Slides(idSlide).CustomLayout.Name
    'Print #iFileNum, ActivePresentation.Slides.getAttribute("layout")
    'For Each oLayoutName In ActivePresentation.Slides().CustomLayouts.Name
    'MsgBox ActivePresentation.Slides(idSlide).CustomLayout.Name
        'Print #iFileNum, oLayoutName.Id & vbTab & oLayoutName.Caption
   ' Next

 Next

  Close iFileNum

End Sub
1

There are 1 answers

4
Steve Rindsberg On

You don't need all that mess with idSlide; oSlide gives you a reference to each slide in the presentation, so:

For Each oSlide In ActivePresentation.Slides
    Debug.Print oSlide.CustomLayout.Name
Next