Written by Allen Wyatt (last updated August 22, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365
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:
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.
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!
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 MoreGetting languages to work correctly in Word can be a challenge at times. In this tip you'll find some ideas for how to ...
Discover MoreWhat is the easiest way to switch between English spelling variants in a document? This tip examines a couple of ways you ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments