Class Characters (Word VBA)

A collection of characters in a selection, range, or document. There is no Character object; instead, each item in the Characters collection is a Range object that represents one character. To use a Characters class variable it first needs to be instantiated, for example


Dim chrs as Characters
Set chrs = ActiveDocument.Range.Characters

Count

Returns the number of characters in the Characters collection.


Dim lngCount As Long
lngCount = ActiveDocument.Range.Characters.Count

First

Returns a Range object that represents the first character in the collection.


Dim rngFirst As Range
Set rngFirst = ActiveDocument.Range.Characters.First

Item

Returns an individual Range object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position of the individual object.


Dim rngCharacter As Range
Set rngCharacter = ActiveDocument.Range.Characters(Index:=1)

Last

Returns a Range object that represents the last character in the collection.


Dim rngLast As Range
Set rngLast = ActiveDocument.Range.Characters.Last