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.
- First, make sure your presentation has a solid background, or that the text boxes are filled in a solid color.
- Next, select each word or set of words that will become a fill-in-the-blank and change its color to red. Pure RGB 255,255,255 red.
- Edit the code below to change the lChangeToColor value to your background color.
- Run the cold on a COPY of your original presentation.
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.