Remove underlines from descenders
Problem
When you underline text that includes lowercase characters, the results can be ugly. The underlines intersect the the descenders of characters like g, j, p, q and y (that is, characters that descend below the baseline).
PowerPoint MVP Geetesh Bajaj discusses the problem in more detail and explains how to fix it manually here on Indezine.com in his article Stop Underlining Your Descenders.
Fixing a few lines of underlined text is well worth the minimal effort it takes; it really does improve the appearance of your text. But what if you've got lots of text to fix? A whole presentation worth? Several whole presentations worth?
Doing it manually would be very tedious indeed. How about letting the computer do the work for you instead? Read on ...
Solution
The VBA code below will look at each text shape in your presentation and remove the underline from any character with descenders.
If you're working in a language with other characters that have descenders, add them to the sDescenders = "gjpqy" line in Function IsDescender below.
Sub FixAllDescenders()
' Removes underlines from all descenders in the presentation
Dim oSl As Slide
Dim oSh As Shape
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
FixDescenders oSh
End If
End If
Next
Next
End Sub
Sub FixDescenders(oSh As Shape)
' Removes underlines from descenders in just the current shape
Dim x As Long
Dim oChar As TextRange
With oSh
If .HasTextFrame Then
If .TextFrame.HasText Then
For x = 1 To Len(.TextFrame.TextRange.Text)
If IsDescender(Mid$(.TextFrame.TextRange.Text, x, 1)) Then
.TextFrame.TextRange.Characters(x, 1).Font.Underline = False
End If
Next
End If
End If
End With
End Sub
Function IsDescender(sCharacter As String) As Boolean
Dim sDescenders as String
sDescenders = "gjpqy"
If InStr(sDescenders, sCharacter) > 0 Then
IsDescender = True
Else
IsDescender = False
End If
End Function
See How do I use VBA code in PowerPoint? to learn how to use this example code.