Document.TextEncoding Property (Word)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Returns or sets the code page, or character set, that Microsoft Word uses for a document saved as an encoded text file. Read/write MsoEncoding.

expression .TextEncoding

expression Required. A variable that represents a Document object.

The TextEncoding property sets text encoding separately from HTML encoding, which you can set using the Encoding property. To set text encoding for all documents saved as text files, use the DefaultTextEncoding property.

This example sets the text encoding for the active document to Japanese if it is saved as a text file.

Sub EncodeText() 
 ActiveDocument.TextEncoding = msoEncodingJapaneseShiftJIS 
End Sub