View Single Post
Old 10-20-2016, 12:54 AM   #9
sjhawar
Member
sjhawar began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Oct 2016
Device: none
Quote:
Originally Posted by DiapDealer View Post
A plugin could also be written that could access a user dictionary and attempt to italicize the words it contains. But it would prove problematic determining whether or not a particular word was already italicized or not.
A Plugin is a good idea to help many users. If a particular word was already italicized, no need to italicize again. Is the following helpful to you?
http://www.codeproject.com/Tips/1003...n-a-Word-Docum
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
sjhawar is offline   Reply With Quote