Word: Macro to set the language for most elements

October 14, 2011

I needed to set the language for all elements of a Word 2007 template to English (Australia). I could set the language for the body of the document easily enough via a simple macro, but this didn’t set the language for the headers, footers, text boxes, or the styles (yes, you can set the language for a style!). (Update September 2018: I now have a macro for setting the language for all styles at once: https://cybertext.wordpress.com/2018/09/21/word-macro-to-set-the-language-for-all-styles/)

So I asked over at the Microsoft Answers forums and the ever-helpful Greg Maxey came up with this macro, which sets the language for all elements of the document, except the styles. As I had fewer than 20 styles in the template, setting the language for those manually wasn’t an arduous task.

Here’s Greg’s macro — change the language from wdEnglishAUS (two places) if you don’t want Australian English (links to the available languages after the macro).

Public Sub SetLangAllRanges()
Dim rngStory As Word.Range
Dim lngJunk As Long
Dim oShp As Shape
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each rngStory In ActiveDocument.StoryRanges
  'Iterate through all linked stories
    On Error Resume Next
    rngStory.LanguageID = wdEnglishAUS
    Select Case rngStory.StoryType
      Case 6, 7, 8, 9, 10, 11
        If rngStory.ShapeRange.Count > 0 Then
          For Each oShp In rngStory.ShapeRange
            If oShp.TextFrame.HasText Then
               oShp.TextFrame.TextRange.LanguageID = wdEnglishAUS
            End If
        End If
      Case Else
        'Do Nothing
    End Select
    On Error GoTo 0
    'Get next linked story (if any)
    Set rngStory = rngStory.NextStoryRange
  Loop Until rngStory Is Nothing
End Sub

Languages available in Word, with their wd language ID code:

[Links last checked April 2021; if this macro has helped you, consider making a small donation of thanks to Greg at http://gregmaxey.mvps.org/word_tips.htm]


  1. […] newsletter/blog of CyberText Consulting – technical communication specialists « Word: Macro to set the language for most elements Word: Set the language for a style October 17, 2011 As a follow-up to my post about […]

  2. […] Word: Macro to set the language for most elements (cybertext.wordpress.com) Share this:DiggTwitterFacebookLike this:LikeBe the first to like this post. […]

  3. hey.. is it possible to find out english text in french document. i have avery huge document of 500 pages.. i want to run a macro to highlight the text if its in english.. is there any way.. because doing it manually will be very cumbersome

  4. Two things–you can (relatively) easily find paragraphs where the language is set to English, which might suit your needs (if the language was set in those paragraphs). With a macro, you might find paragraphs where the spell-checking was set to English (or to none).

    Second thing, which is a question I’m having. I have some templates that I inherited, and clearly the person(s) involved had no idea about certain things (there are paragraphs set in a style where the only difference from normal is the colour and italics, and they have modified them to be roman and the same colour as Normal…) Anyway, documents that emanate from this group have Language: Asian (Korean) set on Normal and all dependent styles. I cannot seem to find where this is set; the Office Tools Language doesn’t find it, the lovely macro here doesn’t affect styles, the style itself doesn’t contain that language. (It has Korean, but that’s not the same description.)

    The word “Asian” doesn’t even show up in the Registry, so I’m inclined to think it’s not Windows specifically.


  5. Hi jhmcmullen

    Just guessing here…

    I wonder if the ‘Asian (Korean)’ has come in from an earlier version of Word? You said you inherited these documents, so perhaps they were originally created in Word 2000/2003 or a Mac version where perhaps the language offerings were listed differently.

    Have you saved this document to a newer version of Word? Can you then set the language either using the macro above or via the individual styles?


  6. […] have a macro for setting the language for all ‘ranges’ in a document, but I needed something to change the language settings for ALL styles in one command. After a bit […]

  7. […] done on this one as yet—run the two macros I have for setting the language for most elements (https://cybertext.wordpress.com/2011/10/14/word-macro-to-set-the-language-for-most-eleme/) and for all styles […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: