Home » Proofing language

Tag: Proofing language

Creating a PowerPoint macro with ChatGPT

🧠 Did you know you can use AI to create macros?

I used ChatGPT to create a PowerPoint macro to change the proofing language for all text in a presentation to UK English.

I often get given decks written by multiple authors in different locations. This leads to different text boxes having different language settings (usually a mixture of US and UK English, but sometimes German!), which raises a lot of false positives when running a spell check. So this is going to save me a lot of time 😁

I have written my own PowerPoint macros in the past, but I don’t have the VBA object model stored in my head, and it’s a pain having to consult the documentation for every little thing. I thought this was probably something that ChatGPT could do much quicker than me.

For my first try, I used this prompt:

write a PowerPoint macro that will change the proofing language on all text boxes to English (UK)

This generated the following macro:

Sub ChangeProofingLanguageToUK()
    Dim slide As slide
    Dim shape As shape
    
    ' Loop through all slides in the presentation
    For Each slide In ActivePresentation.Slides
        
        ' Loop through all shapes in the slide
        For Each shape In slide.Shapes
            
            ' Check if the shape is a text box
            If shape.HasTextFrame Then
                
                ' Set the proofing language to English (UK)
                shape.TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUK
                
            End If
            
        Next shape
        
    Next slide
    
    MsgBox "Proofing language changed to English (UK) for all text boxes.", vbInformation
End Sub

It also gave some helpful instructions on how to install and run it, which were a useful reminder.

  1. Press Alt + F11 to open the VBA editor in PowerPoint.
  2. Insert a new module by right-clicking on the project in the left pane, choosing Insert, and then Module.
  3. Copy and paste the above code into the module.
  4. Close the VBA editor.
  5. Press Alt + F8, choose ChangeProofingLanguageToUK, and click Run.

I tested it, and it worked! 🎉

But it didn’t change the default language for the whole presentation. So I asked it to do that too, and it gave me an additional step:

    ' Set the default proofing language for the entire presentation
    ActivePresentation.DefaultLanguageID = msoLanguageIDEnglishUK

Here is the final macro that I ended up using.

Sub ChangeProofingLanguageToUK()
    Dim slide As slide
    Dim shape As shape
    
    ' Loop through all slides in the presentation
    For Each slide In ActivePresentation.Slides
        
        ' Loop through all shapes in the slide
        For Each shape In slide.Shapes
            
            ' Check if the shape is a text box
            If shape.HasTextFrame Then
                
                ' Set the proofing language to English (UK)
                shape.TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUK
                
            End If
            
        Next shape
        
    Next slide
    
    ' Set the default proofing language for the entire presentation
    ActivePresentation.DefaultLanguageID = msoLanguageIDEnglishUK
    
    MsgBox "Proofing language changed to English (UK) for the whole presentation.", vbInformation
End Sub

Feel free to use (or adapt) this macro yourself if you would find it useful in your own work.