First a little history — look at our Stop Underlining Your Descenders! article — of course, as per that article you can manually remove underlines from all characters such as g, j, p, q, and y that sport descenders. However, the task of individually selecting characters to remove underlines is fine if you need to do so for an important slide title or just your opening slide.
What if you want to do the same task for an entire presentation, as shown in just one slide below?
OK, we understand that no one has a complete presentation full of underlined text — we are just exploring a proof-of-concept here! You’ll soon realize that this is too much work to do! Especially since you can do this task in PowerPoint super-quickly using some simple VBA code, as Steve Rindsberg of PowerPoint FAQ explains.
First you need to know how you can run VBA scripts in PowerPoint — then use this code. Explore the code a bit though since Steve has put in some helpful comments so that you can edit some values as required.
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) > 1 Then IsDescender = True Else IsDescender = False End If End Function
Once you have placed this code in the VBA editor, close the window to get back to your PowerPoint window. Before you proceed further, it’s a great idea to save your file — be sure to save as a PowerPoint Macro-Enabled Presentation with the PPTM file extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then of course the code to remove underlines from descenders will not work! See our PowerPoint File Formats page to learn about these file formats.
Then open or switch to the presentation with the underlined text and run the macro. To do that, press the Alt+F8 shortcut key. In the Macro dialog box that appears, next to Macro in: choose All open presentations, as shown in the figure below. Click the FixAllDescenders Macro name, and then click the Run button.
The code looks at underlined text throughout your presentation, and removes underlines from characters that have descenders. In fact Steve made the code flexible enough so that you could add exceptions or include some other characters too! This code is also available on Steve’s site — and he will update it as required.
Look at the figure below to see the same slide we explored earlier on this page — the slide below has underlines removed from characters with descenders.
Thank you so much, Steve.
We tested this code using PowerPoint 2010 for Windows. Also, we have not checked this on PowerPoint 2013 for Windows (or 2011 for Mac) — if you do, and it does work or not — then we request you leave a comment below this post and share your thoughts. Of course you should share your thoughts even if you are a Windows user.
Steve Rindsberg has been associated with PowerPoint since the product originated more than two decades ago — his PowerPoint FAQ site is a treasure trove of PowerPoint information.
When he’s not updating his site, he’s working on his popular PPTools add-ins for PowerPoint. Steve’s also into a lot of print technology related stuff.
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.