Main Page/Stuff/PowerPoint Add-ins/pageXofY code

From phurvitz
Jump to: navigation, search

<source lang="vb"> Sub UpdateFooter()

' Macro to add "X of Y" (page numbers) to each slide's footer. Dim Name As String Dim ocust As CustomLayout Dim odes As Design Dim osld As Slide Dim varNumberPages As Integer Dim pageNum As Integer varNumberPages = ActivePresentation.Slides.Count

Debug.Print (varNumberPages)


Name = ActivePresentation.Name

For Each odes In ActivePresentation.Designs

With odes.SlideMaster.HeadersFooters.Footer .Visible = msoTrue .Text = varNumberPages End With

For Each ocust In odes.SlideMaster.CustomLayouts

With ocust.HeadersFooters.Footer .Visible = msoTrue .Text = varNumberPages End With Next ocust Next odes

' Updates the individual slides that do not follow the master.

For Each osld In ActivePresentation.Slides With osld.HeadersFooters.Footer pageNum = osld.SlideNumber .Visible = msoTrue .Text = pageNum & " of " & varNumberPages End With Next osld

End Sub </source>