Language Object

See Also         Properties                 

Application object
Languages collection (Language object)
Dictionaries collection (Dictionary object)

Represents a language used for proofing or formatting in Word. The Language object is a member of the Languages collection.

Using the Language Object

Use Languages(index) to return a single Language object, where index can be the value of the Name property, the value of the NameLocal property, one of the WdLanguageID constants, or one of the MsoLanguageID constants. (For the list of valid WdLanguageID or MsoLanguageID constants, see the Object Browser in the Visual Basic Editor.)

The Name property returns the name of a language, whereas the NameLocal property returns the name of a language in the language of the user. The following example returns the string "Italiano" for Name and "Italian (Standard)" for NameLocal when it's run in the U.S. English version of Word.

Msgbox Languages(wdItalian).Name
Msgbox Languages(wdItalian).NameLocal

Returning the Active Proofing Dictionaries

For each language for which proofing tools are installed, you can use the ActiveGrammarDictionary, ActiveHyphenationDictionary, ActiveSpellingDictionary, and ActiveThesaurusDictionary properties to return the corresponding Dictionary objects. The following example returns the full path for the active spelling dictionary used in the U.S. English version of Word.

Set myspell = Languages(wdEnglishUS).ActiveSpellingDictionary
MsgBox mySpell.Path & Application.PathSeparator & mySpell.Name

Setting the Writing Style

The writing style is the set of rules used by the grammar checker. The WritingStyleList property returns an array of strings that represent the available writing styles for the specified language. The following example returns the list of writing styles for U.S. English.

WrStyles = Languages(wdEnglishUS).WritingStyleList
For i = 1 To UBound(WrStyles)
    MsgBox WrStyles(i)
Next i

Use the DefaultWritingStyle property to set the default writing style you want Word to use.

Languages(wdEnglishUS).DefaultWritingStyle = "Casual"

You can override the default writing style with the ActiveWritingStyle property. This property is applied to a specified document for text marked in a specified language. The following example sets the writing style to be used for checking U.S. English, French, and German for the active document.

With ActiveDocument
    .ActiveWritingStyle(wdEnglishUS) = "Technical"
    .ActiveWritingStyle(wdFrench) = "Commercial"
    .ActiveWritingStyle(wdGerman) = "Technisch/Wiss"
End With

Remarks

You must have the proofing tools installed for each language you intend to check. For more information on working in other languages, see Language-specific information.

If you mark text as wdNoProofing, Word skips the marked text when running a spelling or grammar check. To mark text for a specified language or for no proofing, use the Set Language command (Tools menu, Language submenu).