Consulting

Results 1 to 19 of 19

Thread: Macro to change language for all boxes in a presentation

  1. #1
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location

    Macro to change language for all boxes in a presentation

    Hello everybody,

    I have been struggling with a problem for a while. I have some presentations in spanish, but powerpoint (on Macbook) detects it as english and marks all words as spelling mistakes. I need to be able to mark all the boxes from all the slides as "Spanish" to make the spelling mistake detections disappear and make Powerpoint understand that the whole presentation is in Spanish. I have tried all "simple" solutions for a while without success, and I am now asking for help to build a macro to do it. I have seen in the youtube video (link below) that they have built such a macro working on Microsoft, and I would need the same for Macbook.

    Is anybody here able to help me?

    link:
    https://www.youtube.com/watch?v=ME1EPXFe_fc

  2. #2
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,237
    Location
    Does this work?
    Option Explicit
    Public Sub ChangeSpellCheckingLanguage()
    Dim j as Integer
    Dim k as Integer
    Dim scount as Integer
    Dim fcount as Integer
    scount = ActivePresentation.Slides.Count
    For j = 1 to scount 
       fcount = ActivePresentation.Slides(j).Shapes.Count
          For k = 1 to fcount
             If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
                ActicePresentation.Slides(j).Shapes(k).TextFrame2.TextRange.LanguageID = msoLanguageIdSpanish
             End If
         Next k
    Next j
    End Sub
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    OMG YOU ARE THE BEST
    You cannot imagine how much that helps me
    Is there any tipping system in this kind of website ?

  4. #4
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,237
    Location
    Not for me my friend. I simply went online and researched the issue for you.
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by Aussiebear View Post
    Not for me my friend. I simply went online and researched the issue for you.
    Thank you very much!

  6. #6
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by Aussiebear View Post
    Does this work?
    Option Explicit
    Public Sub ChangeSpellCheckingLanguage()
    Dim j as Integer
    Dim k as Integer
    Dim scount as Integer
    Dim fcount as Integer
    scount = ActivePresentation.Slides.Count
    For j = 1 to scount 
       fcount = ActivePresentation.Slides(j).Shapes.Count
          For k = 1 to fcount
             If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
                ActicePresentation.Slides(j).Shapes(k).TextFrame2.TextRange.LanguageID = msoLanguageIdSpanish
             End If
         Next k
    Next j
    End Sub
    Hi Aussiebear, thanks again, you macro is helping me a lot I have a question: do you know how to also include the "notes" section in the macro? (the part at the bottom of every slide?)

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,057
    Location
    Try this

    Sub toSpanish()
    Dim osld As Slide
    Dim oshp As Shape
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    For Each oshp In osld.NotesPage.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    Next osld
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by John Wilson View Post
    Try this

    Sub toSpanish()
    Dim osld As Slide
    Dim oshp As Shape
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    For Each oshp In osld.NotesPage.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    Next osld
    End Sub
    Thank you John but it doesn't work: i've put in color the text that powerpoint told me there is a problem with (see above)

  9. #9
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,057
    Location
    Pretty sure it does work

    Did you copy paste the code?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  10. #10
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by John Wilson View Post
    Pretty sure it does work

    Did you copy paste the code?
    Yes here is the copy screen. Could the reason be that I am working on a Macbook?

    Captura de Pantalla 2022-09-26 a las 22.12.57.jpg

  11. #11
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,057
    Location
    It could be because you have a Mac. I know that LanguageID wasn't supported in earlier Mac VBA but I thought it was fixed in newer versions. You may need to work with TextRange2 like this

    Sub toSpanish()
    Dim osld As Slide
    Dim oshp As Shape
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    For Each oshp In osld.NotesPage.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    Next osld
     End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  12. #12
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by John Wilson View Post
    It could be because you have a Mac. I know that LanguageID wasn't supported in earlier Mac VBA but I thought it was fixed in newer versions. You may need to work with TextRange2 like this

    Sub toSpanish()
    Dim osld As Slide
    Dim oshp As Shape
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    For Each oshp In osld.NotesPage.Shapes
    If oshp.HasTextFrame Then
    oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
    End If
    Next oshp
    Next osld
     End Sub
    That works thank you John!!

  13. #13
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by Aussiebear View Post
    Does this work?
    Option Explicit
    Public Sub ChangeSpellCheckingLanguage()
    Dim j as Integer
    Dim k as Integer
    Dim scount as Integer
    Dim fcount as Integer
    scount = ActivePresentation.Slides.Count
    For j = 1 to scount 
       fcount = ActivePresentation.Slides(j).Shapes.Count
          For k = 1 to fcount
             If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
                ActicePresentation.Slides(j).Shapes(k).TextFrame2.TextRange.LanguageID = msoLanguageIdSpanish
             End If
         Next k
    Next j
    End Sub
    Hello! Thanks again for all the help so far. I have noticed that the macro works perfectly for all text boxes, except for the text boxes grouped with another element (in my case some text boxes are grouped with arrows or numbers so that they stick to each other when I move them). Any idea how to include them too?

  14. #14
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,237
    Location
    What is this group of text boxes called?
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  15. #15
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by Aussiebear View Post
    What is this group of text boxes called?
    Thanks Aussiebear for trying to help. Here you can see in red one of the shapes I am talking about. It seems to be the same name structure, but they are marked as a sub-category.

    Captura de Pantalla 2022-09-30 a las 9.44.47.jpg

  16. #16
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,237
    Location
    They are not "Google" shapes. They belong to "Word".
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  17. #17
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by Aussiebear View Post
    They are not "Google" shapes. They belong to "Word".
    Oh ok sorry for that, how can I then check how are they called? I have just taken normal text boxes and grouped them with objects or other text boxes

  18. #18
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,057
    Location
    Try

    Sub toSpanish()
    Dim osld As Slide
    Dim oshp As Shape
    Dim L As Long
    For Each osld In ActivePresentation.Slides
       For Each oshp In osld.Shapes
          If oshp.Type = msoGroup Then
            For L = 1 To oshp.GroupItems.Count
               If oshp.GroupItems(L).HasTextFrame Then
                  oshp.GroupItems(L).TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
               End If
               Next L
            End If
        If oshp.HasTextFrame Then
           oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
        End If
    Next oshp
    For Each oshp In osld.NotesPage.Shapes
       If oshp.HasTextFrame Then
          oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
       End If
    Next oshp
    Next osld
     End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  19. #19
    VBAX Regular
    Joined
    Nov 2021
    Posts
    11
    Location
    Quote Originally Posted by John Wilson View Post
    Try

    Sub toSpanish()
    Dim osld As Slide
    Dim oshp As Shape
    Dim L As Long
    For Each osld In ActivePresentation.Slides
       For Each oshp In osld.Shapes
          If oshp.Type = msoGroup Then
            For L = 1 To oshp.GroupItems.Count
               If oshp.GroupItems(L).HasTextFrame Then
                  oshp.GroupItems(L).TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
               End If
               Next L
            End If
        If oshp.HasTextFrame Then
           oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
        End If
    Next oshp
    For Each oshp In osld.NotesPage.Shapes
       If oshp.HasTextFrame Then
          oshp.TextFrame2.TextRange.LanguageID = msoLanguageIDSpanish
       End If
    Next oshp
    Next osld
     End Sub
    It works THANK YOU!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •