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 SlideDim oSh As ShapeFor Each oSld In ActiveWindow.Selection.SlideRangeFor x = oSld.Shapes.Count To 1 Step -1Set oSh = oSld.Shapes(x)If oSh.HasTextFrame = True ThenIf oSh.Name Like "Titl*" Or _oSh.Name Like "Subtitle*" Or _oSh.Name Like "Text*" Or _oSh.Name Like "Content*" _ThenIf oSh.TextFrame.HasText ThenoSh.TextFrame2.TextRange.LanguageID = msoLanguageIDEnglishUSElseoSh.DeleteEnd IfEnd IfEnd IfIf oSh.HasTable = True ThenFor r = 1 To oSh.Table.Rows.CountFor c = 1 To oSh.Table.Columns.CountoSh.Table.Cell(r, c).Shape.TextFrame2.TextRange.LanguageID = msoLanguageIDEnglishUSNextNextEnd IfNext xNext oSldEnd 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
Post a Comment