Search code examples
powerpointnaming

Adding Section/Chapter label to slide header


I'm wondering if Powerpoint has a feature where I can automatically add a formatted header to each slide that displays the section and/or chapter. I'm presenting my thesis, and it is divided into sections, like "method" or "evaluation", and I would love it if I could automatically display that in the header of each slide. Preferrably, this would be automatically fetched from my powerpoint sections.

I want this look, which I'm currently producing manually for each slide.

enter image description here


Solution

  • Here's a bit of starter code to get you the name of the section each slide belongs to. Over to you to provide the code to add the text to each slide and position/format it.

    Sub Test()
        Dim oSl As Slide
            ' Make sure there ARE sections
            If ActivePresentation.SectionProperties.Count > 0 Then
            For Each oSl In ActivePresentation.Slides
                Debug.Print GetSection(oSl)
            Next
        End If
    End Sub
    
    Function GetSection(oSl As Slide) As String
    ' Returns the name of the section that this slide belongs to.
    
    With oSl
        Debug.Print .sectionIndex
        GetSection = ActivePresentation.SectionProperties.Name(.sectionIndex)
    End With