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

Updated version uploaded on 1 December 2022. This updated version includes a correction of the error that was in the video and other minor tweaks, and it now updates the language in certain cases where it previously did not work.

Ever felt frustrated when Word keeps selecting the wrong language every time you add a comment? This video explains how to change the language for all elements of a Word document, including footnotes, comments and text boxed, in an instant.

The macro code is below. The video explains how to import the code. Note that near the top of the code, sandwiched between asterisks, there is a line you may need to change, depending on the language and variety that you want to use.

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


Sub LanguageAllStyles()

Dim LanguageId As MsoLanguageID

'***************
LanguageId = msoLanguageIDEnglishUK ' Insert the Name or the Value listed at https://learn.microsoft.com/en-us/office/vba/api/word.wdlanguageid.

'***************

' 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-languageDim 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, oStor As Range

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 = LanguageId
On Error GoTo 0
Next
End With

With oDoc
For Each oStor In .StoryRanges
StatusBar = "Setting story " & oStor & " to language " & LanguageId
oStor.LanguageId = LanguageId
Next oStor
End With

ActiveDocument.Range.LanguageId = LanguageId ' 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 of all sections of the document has been set to " & LanguageId & ". If you wanted to select another language, open the VBA editor by pressing alt+f11 and change the 'LanguageID' shown at the top of the script")
End Sub

Share: