Microsoft Powerpoint

The educational technology and digital learning wiki
Jump to navigation Jump to search

Introduction

this page can be used to write down some powerpoint tricks

Change proofing language

If you use very simple slides, i.e. the "official" bullets then you simply can change by going to outline view, select all and the change the proofing language.

If on the other you work with textboxes (like I do) this won't help and changing language is a huge pain

The following macro found at superuser, made by sancho.s can do the trick. The same forum entry and others list other solutions. I just took the first one that looked OK. It is tested with Office 2016 (but also should work with older and newer versions)

  • Save your pptx ass pptm (macro-enabled powerpoint)
  • Go to view->Macros
  • Create a new macro
  • Copy/paste the code
  • Adapt the language from the official list
  • Save
  • Then run the macro. You can run it again from the Macros view.
Sub en2fr()
    'ChangeLangOfAllText (msoLanguageIDEnglishUS)
    ChangeLangOfAllText (msoLanguageIDSwissFrench)
End Sub

Private Function ChangeLangOfAllText(ByVal LangID As Long)
    Dim MySlide As Slide
    Dim MyShape As Shape
    Dim MyD As Design
    Dim MyHeaderFooter As HeaderFooter
    Dim i, nbs As Integer
    ''''' First deal with the master slides
    For Each MyD In ActivePresentation.Designs
        For Each MyShape In MyD.SlideMaster.Shapes
            ProcessShapes MyShape, LangID
        Next MyShape
    Next MyD
    ''''' Now deal with the slides
    ' Enable this for debugging
    'Debug.Print "File " & ActivePresentation.Name & _
      ": working with " & ActivePresentation.Slides.Count & " slides"
    For Each MySlide In ActivePresentation.Slides
        ' Enable this for debugging
        'Debug.Print " Slide index " & MySlide.SlideIndex & ", Slide number " & MySlide.SlideNumber & _
          ": working with " & MySlide.Shapes.Count & " shapes"
        For Each MyShape In MySlide.Shapes
            ProcessShapes MyShape, LangID
        Next MyShape
        ''''' Now deal with the Notes
        For Each MyShape In MySlide.NotesPage.Shapes
            ProcessShapes MyShape, LangID
        Next MyShape
        ''''' Now deal with the master ' doesn't appear to work, have to try something else
        For Each MyShape In MySlide.Master.Shapes
            ProcessShapes MyShape, LangID
        Next MyShape
    Next MySlide
End Function

Private Function ProcessShapes(MyShape As Shape, ByVal LangID As Long)
    Dim i As Integer
    If ((MyShape.Type = msoGroup) Or (MyShape.Type = msoTable)) Then
        On Error Resume Next
        For i = 1 To MyShape.GroupItems.Count
            ''' The trick is to recurse!
            ProcessShapes MyShape.GroupItems.Item(i), LangID
        Next i
    Else
        ChangeLang MyShape, LangID
    End If
End Function

Private Function ChangeLang(MyShape As Shape, ByVal LangID As Long)
    Dim i As Integer
    If (MyShape.HasTextFrame) Then
        ' Enable this for debugging
        'Debug.Print " Shape " & MyShape.ZOrderPosition & ", type: " & MyShape.Type & _
          ", has text frame: " & MyShape.HasTextFrame & ", has text: " & MyShape.TextFrame.HasText & _
          ", alt. text: " & MyShape.AlternativeText
        MyShape.TextFrame.TextRange.LanguageID = LangID
    End If
End Function

To do: Check a proper add-on, e.g. https://github.com/wobba/officeaddin/releases , probably a much better solution.