python - 在 Python 中使用 COM 的 MS Word 表对象“不可索引”
问题描述
我正在尝试使用 COM 接口自动适应 word 文档中存在的所有表的内容。我面临“表格对象不可索引”的问题。如何使用python win32从word文档中获取表格对象?
代码(不工作):
def TableAutoFit():
MsWord = Sys.OleObject["Word.Application"] #using TestComplete and not win32com.Both use COM objects.
if MsWord.ActiveDocument.Tables.Count > 0:
MsWord.Browser.Target = 7
for table in MsWord.ActiveDocument.Range().Tables:
table.AutoFitBehavior(1)
解决方案
推荐阅读
- linux - WebDriverException:/usr/bin/google-chrome-stable 中没有 chrome 二进制文件或找不到 chrome 二进制文件
- flutter - Flutter:NoSuchMethodError(NoSuchMethodError:方法'[]'在null上被调用
- r - 问题:qqplot图例线型不同
- java - 按字符串长度降序对字符串列表进行排序,不会更改列表
- javascript - 显示 dom 中的第一个元素并隐藏其他所有使用 css 的 angular
- verilog - Verilog 使用负沿 JK 触发器测试台问题构建同步 4 位计数器
- assembly - 从iso镜像启动为什么bootloader的内存地址不是0x7c00
- php - 将 PHP 数组中的每个值显示为 HTML 中的图像
- json-ld - 如何在 C# 中使用 dotNetRDF 解析 JSON-LD 提要
- php - 在 PHP 中过滤 Json 项目