Characters Collection

The Characters collection is Read-Only and represents all the characters in a specified range or selection.
Each item in the characters collection is a Range object. There is no Character object.


Characters(index) - where index is the index number
This obtains the first character in the current selection and assigns it to a Range object.

Dim objRange As Range 
objRange = ActiveWindow.Selection.Characters.Item(1)
sChar = objRange.Text

It is also possible to refer to the Range properties and methods directly.

sChar = ActiveWindow.Selection.Characters.Item(1).Text 


Count Property (Read Only)

The Count property returns the total number of characters (as a Long).

Dim lTotal As Long 
lTotal = ActiveWindow.Selection.Characters.Count

This displays the total number of characters in the first sentence of the active document

lTotal = ActiveDocument.Sentences(1).Characters.Count 




© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext