首页/ 接口索引/ Text 文本对象

shape.Text.Story.Characters

字符集合。.Count 拿字数,.Item(i) 拿单个字符。

签名

shape.Text.Story.Characters

说明

字符集合。.Count 拿字数,.Item(i) 拿单个字符。

Python 示例(可直接运行)

依赖 pywin32。示例假定 app / doc / page / layer 已就绪。 见「连接与初始化」
Python
shape = app.ActiveSelectionRange(1)
chars = shape.Text.Story.Characters

print("总字符数:", chars.Count)

# 逐字读取(第 1 个是第一个字)
for i in range(1, min(chars.Count + 1, 6)):
    print(i, repr(chars.Item(i).Text))

关于本类:Text 文本对象

文字接口分两层:Shape.Text 是入口,真正读写字体字号要下到 Story.Characters.All。

同类其他接口