How do I show the Slide ID of a single slide?

If you’ve decided that the logic of using Slide IDs to delete¬†(or otherwise update) slides in a presentation is the way you’d like to proceed towards VBA coding your PowerPoint updates, you will undoubtedly need a handy way of deciphering the precise values of those Slide IDs that you have in your presentation.

A super easy way would be to run a code that will get you the Slide ID and its corresponding slide title in a message box.

This is exactly what the snippet below does upon entering the “requested” slide PowerPoint position in the input box that pops up upon triggering the routine.

Sub ShowSlideID()
Dim p As Presentation
Set p = ActivePresentation
Dim No As Integer
Dim i As Integer
i = InputBox("Enter Slide number")
No = p.Slides(i).SlideID
MsgBox (No)
End Sub

If you need to get multiple Slide IDs, however, triggering the same routine over and over again can be a bit tedious.

In such cases you can use the VBA snippet below, which will pop up a message box with the Title and Slide ID for each PowerPoint position you’ve pre-coded

Sub Display_SlideIDs()
Dim i As Integer
Dim PPS As Slide
Dim p As Presentation
Set p = ActivePresentation
For Each PPS In p.Slides
If PPS.SlideIndex = 2 Or PPS.SlideIndex = 4 Or PPS.SlideIndex = 7 Or _
PPS.SlideIndex = 8 Or PPS.SlideIndex = 9 Or PPS.SlideIndex = 10 Or PPS.SlideIndex = 11 Or _
PPS.SlideIndex = 23 Or PPS.SlideIndex = 29 Or PPS.SlideIndex = 52 Then
MsgBox (PPS.Shapes.Title.TextFrame.TextRange & " = " & PPS.SlideID)
End If
Next PPS
End Sub

Happy VBA coding!