Words Interface

A collection of words in a selection, range, or document.

Namespace:  Microsoft.Office.Interop.Word
Assembly:  Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)

Syntax

'Declaration
<GuidAttribute("0002095C-0000-0000-C000-000000000046")> _
Public Interface Words _
    Inherits IEnumerable
'Usage
Dim instance As Words
[GuidAttribute("0002095C-0000-0000-C000-000000000046")]
public interface Words : IEnumerable

Remarks

Each item in the Words collection is a Range object that represents one word. There is no Word object.

Use the Words property to return the Words object.

Use Words(index), where index is the index number, to return a Range object that represents one word. The index number represents the position of the word in the Words collection.

The item in the Words collection includes both the word and the spaces after the word. If the selection is the insertion point and it is immediately followed by a space, Selection.Words(1) refers to the word preceding the selection. If the selection is the insertion point and is immediately followed by a character, Selection.Words(1) refers to the word following the selection.

The Count property for this collection in a document returns the number of items in the main story only. To count items in other stories use the collection with the Range object. Also, the Count property includes punctuation and paragraph marks in the total. If you need a count of the actual words in a document, use the Word Count dialog box.

The Add method isn't available for the Words collection. Instead, use the InsertAfter method or the InsertBefore method to add text to a Range object.

See Also

Reference

Words Members

Microsoft.Office.Interop.Word Namespace