Instructor PPTX VBA - Changing Slide Object's TextFrame and Table Cells Language Property

How to change textbox language to English

If your like me, you find the red squiggly lines in PPTX TextFrames distracting when working with pptx files that have a mismatched language issue.


Here is a script that will:
  • detect how many slides in your presentation
  • for each slide, loop through each shape determining if it has a TextFrame, then...
    • sets the language to EnglishUS while deleting empty TextFrames
  • if  the shape has a table:
    • it sets each table cell to EnglishUS

Sub format_all_textboxes()

    Dim oSld As Slide
    Dim oSh As Shape
    
    For Each oSld In ActiveWindow.Selection.SlideRange
        For x = oSld.Shapes.Count To 1 Step -1
            Set oSh = oSld.Shapes(x)
            If oSh.HasTextFrame = True Then
                If oSh.Name Like "Titl*" Or _
                    oSh.Name Like "Subtitle*" Or _
                    oSh.Name Like "Text*" Or _
                    oSh.Name Like "Content*" _
                Then
                    If oSh.TextFrame.HasText Then
                        oSh.TextFrame2.TextRange.LanguageID = msoLanguageIDEnglishUS
                    Else
                        oSh.Delete
                    End If
                End If
            End If
        
            If oSh.HasTable = True Then
                For r = 1 To oSh.Table.Rows.Count
                    For c = 1 To oSh.Table.Columns.Count
                        oSh.Table.Cell(r, c).Shape.TextFrame2.TextRange.LanguageID = msoLanguageIDEnglishUS
                    Next
                Next
            End If
        
        Next x
    Next oSld
End Sub

I am not a VBA expert, so if you have better ways to do this, please comment and I may update this example with better coding practices.

I used the following sources as references:

Comments

Popular posts from this blog

Advanced Network Security Troubleshooting and Solutions v22.411 (ANSTS)

Arubanetworks Webgate - Copy and Paste instructions