Automatically setting the target language in Word documents

PLEASE NOTE: As of June 3, 2015 CafeTran automatically sets the target language in all stories (headers, footers, text boxes etc.) in MS Word documents.

However, CafeTran replaces the source language with the target language. If there is no source language set in the source documents, the program leaves it as it is.

Source language:

DE.png

Target language:

NL.png

Place this part in the AutoOpen section of your normal.dotx:


Sub AutoOpen()
Application.OnTime Now + TimeValue("00:00:01"), "CT_SetLanguage"
End Sub

Description: https://support.microsoft.com/en-us/kb/286310

Note: Adjust the time value when necessary (big documents, slow computer etc.)

You can add this part in the NewMacros module:
Sub CT_SetLanguage()
Dim rngStory As Word.Range
Dim aShp As Shape
Dim aLanguage As String
Dim aLanguageID As String

aLanguage = LCase(Right(ActiveDocument.Name, 10))

Select Case aLanguage
Case "de-de.docx"
aLanguageID = wdGerman

Case "en-gb.docx"
aLanguageID = wdEnglishUK

Case "fr-fr.docx"
aLanguageID = wdFrench

Case "nl-nl.docx"
aLanguageID = wdDutch

Case "es-es.docx"
aLanguageID = wdSpanish

Case "it-it.docx"
aLanguageID = wdItalian

Case Else
'Do Nothing
aLanguageID = wdNoProofing
End Select

For Each rngStory In ActiveDocument.StoryRanges
'Iterate through all linked stories
Do
On Error Resume Next
rngStory.LanguageID = aLanguageID
Select Case rngStory.StoryType
Case 6, 7, 8, 9, 10, 11
If rngStory.ShapeRange.Count > 0 Then
For Each aShp In rngStory.ShapeRange
If aShp.TextFrame.HasText Then
aShp.TextFrame.TextRange.LanguageID = aLanguageID
End If
Next
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
Next
End Sub

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License