Changing the Language Setting for All Document Text

Written by Allen Wyatt (last updated August 22, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


3

Sharon received a document that includes many tables in it. She selected the entire document using Ctrl+A and then changed the language setting for the document. However, this did not change the language setting for any of the text contained within the tables. Sharon wonders if there is a way to really change the language setting for all text in the document.

In doing some testing, we found that if you have a document that includes tables, when you press Ctrl+A and change the language setting, those paragraphs in the table are also affected, just like regular paragraphs. The only time that this did not occur is if the table was in a "non-body" portion of the document, such as a text box, a shape, header, footer, endnotes, or footnotes. In those instances, the text in those elements was not affected.

The only way to affect each of these areas is to use a macro. For instance, here is a simple macro that will go through each of the StoryRanges in the document and change the language for each paragraph:

Sub ChangeLanguage()
    Dim r As Range
    Dim p As Paragraph

    For Each r In ActiveDocument.StoryRanges
        For Each p In r.Paragraphs
            p.Range.LanguageID = wdEnglishUK
        Next p
    Next r
End Sub

The language setting, in this macro, is set to UK English. If you would like it set to a different language—and there are scores of them—you can use one of the enumerations listed on this page:

https://msdn.microsoft.com/en-us/VBA/Word-VBA/articles/wdlanguageid-enumeration-word

For most folks, the simple macro should work just fine. If you have a more complex document, though, you may still find some areas where the language was not changed. In that case, you may find the macro at the following page helpful:

https://cybertext.wordpress.com/2011/10/14/word-macro-to-set-the-language-for-most-eleme/

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (5227) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using the Organizer to Manage AutoText

There are times you need to move your AutoText entries from one template or document to another. Use Organizer to do this ...

Discover More

Printing Color Separations with VBA

When printing in color (at a commercial printer) it is necessary to print different colors of your document in different ...

Discover More

Using Alternating Styles

Alternating styles can come in handy when you have to switch between one type of paragraph and another, automatically, as ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Specifying a Language for Text

Need to format a paragraph (or some selected text) so that it is a language other than English? You can do so easily by ...

Discover More

Keeping with British English

Getting languages to work correctly in Word can be a challenge at times. In this tip you'll find some ideas for how to ...

Discover More

Changing between English Variants

What is the easiest way to switch between English spelling variants in a document? This tip examines a couple of ways you ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2019-03-02 14:05:35

Iglika

Hello, Mr Wyatt,
First of all I would like to thank You for all the knowledge and really useful tips (even for n00bs in coding like me) You share with the world wide web. Thanks to your 'Writing a Macro from Scratch' and 'Generating a Count of Word Occurrences' articles which I came to via google I now have my first macros up and running. The reason to search for this particular kind of Macros is that as part of a small university team I am trying to find alternative (free) ways to automatize some parts of our content analysis work (we do not have any budget so we will do it manually - without any software). But we are working with texts (articles) written in language that is different form English and with the Sub WordFrequency VBA macro this cannot be done (I guess I have to ad some dim languageID for the goal). I would be beyond than grateful for your help with this case.
Thank You so much for your work and time.
Kind regards


2018-01-29 03:44:35

Richard Price

If the document uses styles that are all based on one style (e.g. Normal), then you don't need any macros. All you have to do is to change the language setting of that master style (right-click on the style in the Styles gallery of the Home tab, select Modify -> Format -> Language). I tried this on a document containing a table and several text boxes, one of which contained another table, and it worked perfectly. You may need to reinitialise the spell checker (File -> Options -> Proofing -> Recheck Document) in order to see the effect of the language change on spell checking.

Of course many documents are created by people who don't understand or choose to use styles, but that shouldn't be a problem because then the whole document will be in the Normal style, in which case the above method still works. It will only fail if the original author has applied a proofing language as _direct_ formatting of content within the document. In that case, the author should be taken aside for a good talking-to.


2018-01-27 06:11:26

Ken Endacott

If there are more than one shape or textbox containing text then the macro ChangeLanguage will only change the language of the text in the first. The following macro ChangeLanguageAll will change the language for the whole document including all textboxes and shapes containing a textframe.

Sub ChangeLanguageAll()
Dim r As Range
Dim p As Paragraph
Dim aShape As Shape
Dim txtFrame As TextFrame

For Each r In ActiveDocument.StoryRanges
For Each p In r.Paragraphs
p.Range.LanguageID = wdEnglishUK
Next p
Next r
For Each aShape In ActiveDocument.Shapes
Set txtFrame = aShape.TextFrame
If Not txtFrame Is Nothing Then _
txtFrame.TextRange.LanguageID = wdEnglishUK
Next aShape
End Sub

Each paragraph has a language property that determines what language dictionary the spell checker will use to check the paragraph. When a new paragraph is created it gets its language setting from the style, thereafter the paragraph’s language can be changed to another language and it will remain until the style is re-applied or another style applied.

Language can also be applied to individual words or groups of words within a paragraph and this overrides the paragraph’s language setting for those words. They can occur if text is copied from another paragraph or another document that has a different language setting. Individual word settings will not change if the paragraph’s style is changed or renewed, the only way to remove them is by selecting the whole paragraph and setting the desired proofing language.

Language can also be applied to individual characters with curious results.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.