Welcome / Bienvenue / Benvinguts / Bienvenidos
For information about my translation services, please visit the main site.
Pour des informations sur mes services, merci de regarder le site principal.
Para información sobre mis servicios de traducción, visite el web principal.

How to change the language in all stories (including comments) in a Word document

I’ll create a full post later explaining what this does in more detail. For now, I’ll just explain that it changes the language setting of EVERYTHING in Word document, including the main text, text boxes and comments. This is particularly useful for translators, who need to change the language of everything and find that pressing ctrl+a doesn’t work.

Here’s the macro code. If you’ve never created a macro manually, you’ll find plenty of help online explaining how to store a macro. Note that there is one line of code that you need to change, depending on the language and variety that you want. The line is sandwiched between a series of asterisks so you can find it easily.

Please leave a comment to let me know whether it works for you.

Sub LanguageAllStyles()

' Macro to change language in styles
' Loosely based on a macro posted by Macropod (17 July 2012)
' http://www.vbaexpress.com/forum/showthread.php?42993-Solved-Macro-to-change-all-styles-to-a-specific-language

Dim TrackChangesActive As Boolean ' Only possible values are True/False
Dim CheckSpellingAsYouTypeActive As Boolean
Dim CheckGrammarAsYouTypeActive As Boolean
Dim ShowFormatChanges As Boolean
Dim doc As Document
Dim SkipTrackChangesQuestion As Boolean

Dim oDoc As Document, oSty As Style

Application.ScreenUpdating = False

'Block taken from my personal "MacroSwitchesOff" code
If Options.CheckSpellingAsYouType = True Then CheckSpellingAsYouTypeActive = True Else CheckSpellingAsYouTypeActive = False ' Checks whether CheckSpellingAsYouType is switched on.
Options.CheckSpellingAsYouType = False
' Forces Word to check everything again with the new language. Cancel the above line if you don't want Word to forget when you've "Ignored" a flagged spelling.
' Without switching this setting off and on, Word still underlines words that are correctly written in the new language.
If Options.CheckGrammarAsYouType = True Then CheckGrammarAsYouTypeActive = True Else CheckGrammarAsYouTypeActive = False
Options.CheckGrammarAsYouType = False
' See previous comment

If ActiveDocument.ActiveWindow.View.ShowFormatChanges = True Then ShowFormatChanges = True Else ShowFormatChanges = False
ActiveDocument.ActiveWindow.View.ShowFormatChanges = False
'Check whether Format changes are shown

If ActiveDocument.TrackRevisions = True Then TrackChangesActive = True Else TrackChangesActive = False

If SkipTrackChangesQuestion <> True Then ' Skip the track changes question
If MsgBox("Perform the operation with track changes?", _
vbYesNoCancel) = vbNo Then
ActiveDocument.TrackRevisions = False
Else
ActiveDocument.TrackRevisions = True
End If
End If

Set oDoc = ActiveDocument
With oDoc
For Each oSty In .Styles
StatusBar = oSty
On Error Resume Next
'************************************************
oSty.LanguageID = wdEnglishUK ' Change as appropriate, using the list at https://docs.microsoft.com/en-us/office/vba/api/word.wdlanguageid
'************************************************
On Error GoTo 0
Next
End With

ActiveDocument.Range.LanguageID = wdEnglishUK ' Uses the normal method, equivalent of pressing ctrl+a and setting the language.

'Block taken from my personal "MacroSwitchesOnAgain" code
' The lines below revert settings to the status they had before the macro was run
If TrackChangesActive = True Then ActiveDocument.TrackRevisions = True
If CheckSpellingAsYouTypeActive = True Then Options.CheckSpellingAsYouType = True
If CheckGrammarAsYouTypeActive = True Then Options.CheckGrammarAsYouType = True
If ShowFormatChanges = True Then ActiveDocument.ActiveWindow.View.ShowFormatChanges = True
ActiveDocument.ActiveWindow.View.ShowFormatChanges = True

Application.ScreenUpdating = True

MsgBox ("Finished! The language might display incorrectly at the bottom of the page and you might still see some underlined words for a while. It's just a screen-refresh problem. If it bothers you, select any character, then change the language.")
End Sub

Share:

4 thoughts on “How to change the language in all stories (including comments) in a Word document

  1. Looks very useful, Tim! Thank you for sharing.
    However, when I run it, it stops at TrackChangesDeletionsHidden_Restore and this debugging message pops up: Compile error: Sub or Function not defined.

Leave a Reply

Your email address will not be published. Required fields are marked *