PDA

View Full Version : [SOLVED:] Macro to change language for all boxes in a presentation



djecris
09-19-2022, 09:37 AM
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

Aussiebear
09-19-2022, 01:33 PM
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

djecris
09-19-2022, 01:53 PM
OMG YOU ARE THE BEST
You cannot imagine how much that helps me
Is there any tipping system in this kind of website ?:D

Aussiebear
09-19-2022, 03:12 PM
Not for me my friend. I simply went online and researched the issue for you.

djecris
09-20-2022, 02:57 AM
Not for me my friend. I simply went online and researched the issue for you.

Thank you very much! :bow:

djecris
09-26-2022, 03:51 AM
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?)

John Wilson
09-26-2022, 04:57 AM
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

djecris
09-26-2022, 05:35 AM
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)

John Wilson
09-26-2022, 08:54 AM
Pretty sure it does work

Did you copy paste the code?

djecris
09-26-2022, 01:15 PM
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?

30170

John Wilson
09-27-2022, 12:32 AM
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

djecris
09-27-2022, 04:39 AM
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!! : pray2:: pray2:

djecris
09-29-2022, 03:16 PM
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?

Aussiebear
09-29-2022, 09:17 PM
What is this group of text boxes called?

djecris
09-30-2022, 12:48 AM
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.

30187

Aussiebear
09-30-2022, 01:44 AM
They are not "Google" shapes. They belong to "Word".

djecris
09-30-2022, 02:07 AM
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

John Wilson
09-30-2022, 11:41 AM
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

djecris
10-01-2022, 02:49 AM
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! :bow: