shape.Text.Range(start, end)
Returns a character range, for local typography like recoloring the first few characters.
Signature
shape.Text.Range(start, end)
Notes
Returns a character range, for local typography like recoloring the first few characters.
Python example (runnable)
Requires
pywin32. The example assumes app / doc / page / layer are already connected.
See Connection & InitPython
shape = app.ActiveSelectionRange(1)
# Range(start, end): style part of a run (1-based)
first3 = shape.Text.Range(1, 3)
print("First three characters: ", first3.Text)
first3.Size = 48 # enlarge just these characters
first3.Fill.UniformColor.RGBAssign(255, 0, 0) # colour just these characters red
print("First three characters enlarged and coloured red")
About this section: Text
Text — artistic and paragraph text.
- This section has 13 entries; this is one of them.
- See the full section index: Text
Other entries in this section
- shape.TextEntry point to the text object. Only exists when shape.Type == 6.
- shape.Text.ContentsPlain text, read/write. strip() before you compare — CDR often leaves
- shape.Text.IsArtisticTextTrue if it's artistic text (a single-line heading).
- shape.Text.IsParagraphTextTrue if it's paragraph text that wraps inside a box.
- shape.Text.StoryThe story object. This is where the real layout properties live.
- shape.Text.Story.CharactersCharacter collection. .Count gives the character count, .Item(i) a sin
- shape.Text.Story.Characters.AllThe whole-character range, and the only reliable way to set font and s
- shape.Text.Story.CharSpacingCharacter spacing, as a percentage. 180 means 180%, loose; 50 tightens