Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Tricks for Teachers

Fill in the blanks tests

You have a set of slides with text. Some of the words will be come the "blanks" in a fill-in-the-blanks exercise when you print the presentation.
Here's a simple way to make this happen.

It'll find each "run" of red text and change it to the lChangeToColor that you specified. Then it'll add a line beneath the text, the same width as the text itself. There's your underline.

Option Explicit

' Run this only on a COPY of your original presentation
Sub RunMeOnACOPYOnly()

Dim oSl As Slide
Dim oSh As Shape
Dim lFindColor As Long
Dim lChangeToColor As Long

' This sets the color we'll look for
lFindColor = RGB(255, 0, 0) ' Red
' This sets the color we'll change it to
lChangeToColor = RGB(255, 255, 255) ' white

With ActivePresentation
    For Each oSl In .Slides
        For Each oSh In oSl.Shapes
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    Call FixText(oSh, lFindColor, lChangeToColor)
                End If
            End If
        Next
    Next
End With

End Sub

Sub FixText(oSh As Shape, lFindColor As Long, lChangeToColor As Long)
    Dim x As Long
    Dim oSl As Slide

    Set oSl = oSh.Parent

    With oSh.TextFrame.TextRange
        For x = 1 To .Runs.Count
            If .Runs(x).Font.Color.RGB = lFindColor Then
                .Runs(x).Font.Color.RGB = lChangeToColor
                With oSl.Shapes.AddLine(.Runs(x).BoundLeft, _
                    .Runs(x).BoundTop + .Runs(x).BoundHeight, _
                    .Runs(x).BoundLeft + .Runs(x).BoundWidth, _
                    .Runs(x).BoundTop + .Runs(x).BoundHeight)
                    .Line.Visible = True
                    .Line.Weight = 2 ' points
                    .Line.ForeColor.RGB = RGB(0, 0, 0)
                End With
            End If
        Next
    End With
End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Tricks for Teachers
http://www.pptfaq.com/FAQ01232-Tricks-for-Teachers.htm
Last update 16 March, 2016
Created: 16 March, 2016