app.Documents
所有已打开文档的集合。取第 i 个:app.Documents.Item(i),共 app.Documents.Count 个。
签名
app.Documents
说明
所有已打开文档的集合。取第 i 个:
app.Documents.Item(i),共 app.Documents.Count 个。Python 示例(可直接运行)
Python
docs = app.Documents # 所有已打开文档的集合
print("打开文档数:", docs.Count) # Count = 元素个数
for i in range(1, docs.Count + 1): # 注意:CDR 集合索引从 1 开始
d = docs.Item(i) # d : 第 i 个文档对象
print(i, d.FileName or "未保存的新文档")
关于本类:Application 应用对象
整个 CDR 进程的入口,主要用来拿文档、拿当前选中、建颜色。
- 本类共 13 条,这是其中之一。
- 完整分类见:Application 应用对象
同类其他接口
- app.ActiveDocument当前激活文档。一个都没开时返回 None,所以要写 try/except 兜底 CreateDocument。
- app.CreateDocument()新建空白文档,返回 Document。
- app.OpenDocument(path)打开磁盘上的 cdr / 模板文件,返回 Document。
- app.ActiveSelectionRange(n)当前选中的第 n 个形状,返回单个 Shape。刚 Import 完图片立刻用它抓图(n 从 1 开始)。
- app.ActiveSelectionRange不带参数返回整个选区(ShapeRange),可 for s in rng 遍历。
- app.ActiveShape当前选区里的第一个形状,等价 ActiveSelectionRange(1)。
- app.ActivePage当前页。等价 ActiveDocument.ActivePage。
- app.ActiveLayer当前图层。等价 ActiveDocument.ActivePage.ActiveLayer。