Add shape with text to "flag" hidden vs unhidden slides
Problem
A presenter uses hidden slides and regular slides in a presentation. The hidden slides are part of a printed guide but not part of the actual presentation.
The presenter wants to print handouts that distinguish which slides are part of the presentation and which are not.
Solution
The following FlagSlides macro will add a colored rectangle in the upper right hand corner of each slide. Its color and text will depend on whether the slide is hidden or not.
You can modify the rectangle position, size, color and text characteristics to suit your needs.
The UnFlagSlides macro will remove the flag shapes that FlagSlides added.
Sub FlagSlides()
Dim oSlides As Slides
Dim oSld As Slide
Set oSlides = ActivePresentation.Slides
For Each oSld In oSlides
If oSld.SlideShowTransition.Hidden Then
' Add a flag shape
With oSld.Shapes.AddShape(msoShapeRectangle, 564#, 0#, 156#, 78#)
' give it a name so we can delete or hide it easily later
.Name = "HIDDEN"
' Change this to whatever you like
With .TextFrame.TextRange
.Text = "HIDDEN SLIDE"
With .Font
'.Name = "Times New Roman"
.Size = 14
.Bold = msoTrue
.Color.RGB = RGB(255, 255, 255)
End With
End With ' text frame
.Fill.ForeColor.RGB = RGB(255, 0, 0)
End With ' newly added shape
Else ' it's NOT hidden so
' Add a flag shape
With oSld.Shapes.AddShape(msoShapeRectangle, 564#, 0#, 156#, 78#)
' give it a name so we can delete or hide it easily later
.Name = "NOT_HIDDEN"
' Change this to whatever you like
With .TextFrame.TextRange
.Text = "NOT HIDDEN SLIDE"
With .Font
'.Name = "Times New Roman"
.Size = 14
.Bold = msoFalse
.Color.RGB = RGB(255, 255, 255)
End With
End With ' text frame
.Fill.ForeColor.RGB = RGB(0, 0, 255)
.Fill.Visible = msoTrue
.Fill.Solid
End With ' newly added shape
End If
Next oSld
End Sub
Sub UNFlagSlides()
Dim oSlides As Slides
Dim oSld As Slide
Set oSlides = ActivePresentation.Slides
On Error Resume Next ' in case user has deleted the "flag" shapes
For Each oSld In oSlides
If oSld.SlideShowTransition.Hidden Then
oSld.Shapes("HIDDEN").Delete
Else ' it's NOT hidden so
oSld.Shapes("NOT_HIDDEN").Delete
End If
Next oSld
End Sub
See How do I use VBA code in PowerPoint? to learn how to use this example code.
Search terms: