Introduction
I am always very annoyed at having to write a document with a great deal of foreign-language terminology. It looks very bad and clumsy unless you do something that highlights these words, for example in Dutch:
De targets die de Raad van Bestuur stelde waren off limits.
I just wrote a Word macro that can do this automatically for you, The example works for Dutch text and highlights all words that are not recognized as Dutch, but as US/UK English, but it is very easy to adapt to whatever set of languages you would like.
Using the Code
Create a new macro in Word and paste in the following code (tested in version 2010). When you run the macro, all words in your document that are not Dutch, but are US/UK English, are formatted in italics, unless they were already italic, in which case they are formatted normally (assuming that surrounding words are in italics, so we highlight the word in question by making it normally formatted).
Sub ItalicizeEnglish()
If Application.Documents.Count < 1 Then
MsgBox "No documents are open!"
Return
End If
ActiveDocument.Content.LanguageID = msoLanguageIDDutch
ActiveDocument.Content.NoProofing = False
For Each w In ActiveDocument.SpellingErrors
If Not ItalicizeIfInLanguage(w, msoLanguageIDEnglishUS) Then
b = ItalicizeIfInLanguage(w, msoLanguageIDEnglishUK)
End If
Next
End Sub
Function ItalicizeIfInLanguage(w, lan) As Boolean
oldlan = w.LanguageID
w.LanguageDetected = False
w.LanguageID = lan
If w.SpellingErrors.Count = 0 Then
w.Font.Italic = Not w.Font.Italic
ItalicizeIfInLanguage = True
Else
w.LanguageID = oldlan
ItalicizeIfInLanguage = False
End If
End Function
Points of Interest
This is not a very exciting piece of code. I wrote it in 30 minutes with no prior knowledge of VBA, but it is probably very useful. At least for me. :)
History
- Version 1.0 was uploaded on June 24, 2015