Sample code to change the Language ID of a text box in PowerPoint (245468)



The information in this article applies to:

  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002
  • Microsoft PowerPoint 2000

This article was previously published under Q245468

SUMMARY

This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) that searches a presentation for text boxes and changes the LanguageID property of the text box to US English. You can easily modify the code to change the language ID to one of several other languages.

This macro does not change the language of a presentation. It only sets the LanguageID property for each text box to another language. This is useful if you have to change the language ID for all your text boxes at the same time to be able to check the spelling.

This macro can be helpful if you have a presentation that contains text that is set to a LanguageID that cannot be easily found. Additionally, this macro can be helpful if you use it to change something by using the Language dialog box in PowerPoint. This macro is typically needed if you receive the following message when you try to check the spelling of a presentation in PowerPoint: PowerPoint couldn't find the spelling file for <Language>

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Note The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

230746 PPT: Viewer: Presentation Macros Don't Run Within the Viewer

Sample Visual Basic Procedure

Sub Lingo()

   ' Declare variables.
   Dim sld As Slide
   Dim shp As Shape

   ' Loop through all the slides in the presentation.
   For Each sld In ActivePresentation.Slides
       
       ' Loop through each shape on each slide.
       For Each shp In sld.Shapes
           
           ' If the Shape is a text box...
           If shp.Type = msoTextBox Or msoPlaceholder Then
           If shp.HasTextFrame Then
               
               ' ...then change the language to US English.
               ' NOTE: To change the language ID to another language,
               ' change the msoLanguageID value here to a 
               ' different language.
               shp.TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUS
           
           End If
           End If
       Next
   Next

End Sub
				

REFERENCES

For additional information about how to use the sample code that is in this article, click the following article number to view the article in the Microsoft Knowledge Base:

212536 How to run sample code from Knowledge Base articles


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbcode kbdtacode kbhowto kbmacro kbProgramming KB245468