Macro to set language

K

Kamran

Hello,
I'm using the macro recorder to set the language to Spanish, but when I go
to the VB editor, it hasn't recorded anything except for the name of the
macro. I switch frequently between Spanish and English and would like to
have one-button click to do that. I used a modified statement from the Word
VB editor, but it doesn't work:

Selection.LanguageID = msoLanguageIDSpanishModernSort

I'd great appreciate any help with this.
 
B

Bill Dilworth

In Word, your routine would not have effected the text within a text box,
only the body of the text that was selected at the time. In PowerPoint, all
text is contained in objects, so you need to cycle thru each of the objects
on each of the slides and set the language on each object that has text.

So, to change the entire presentation, you could ...
-----
Sub Revolución()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
With oShp.TextFrame.TextRange
If .LanguageID = msoLanguageIDSpanishModernSort Then
.LanguageID = msoLanguageIDEnglishUS
Else
.LanguageID = msoLanguageIDSpanishModernSort
End If
End With
End If
Next oShp
Next oSld
End Sub
------

However, this also has it's issues, since it will not change the text on the
Master slides or text brought in as images. It may be easier just to use
the same method of requiring the text to be selected. In that case, you
could use...

-----
Sub Independencia(oSel As Selection)
If oSel.Type = ppSelectionText Then
With oSel.TextRange
If .LanguageID = msoLanguageIDSpanishModernSort Then
.LanguageID = msoLanguageIDEnglishUS
Else
.LanguageID = msoLanguageIDSpanishModernSort
End If
End With
End If
End Sub
------


Hope this gives you the tools you need to resolve your questions.

Bill Dilworth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top