在 python 中使用 win32com wdGoToPage 引入路径
时间: 2023-02-17 14:03:59 浏览: 279
在 python 中使用 win32com 库访问 Microsoft Word 文档时,可以使用 `wdGoToPage` 方法来跳转到特定页面。
示例代码:
```python
import win32com.client
word = win32com.client.Dispatch("Word.Application")
doc = word.Documents.Open("C:\\path\\to\\document.docx")
word.Selection.GoTo(What=win32com.client.constants.wdGoToPage, Which=win32com.client.constants.wdGoToAbsolute, Count=3)
```
其中,`What` 参数设置为 `wdGoToPage`,`Which` 参数设置为 `wdGoToAbsolute`,`Count` 参数设置为要跳转到的页码。
请注意,使用 win32com 需要在计算机上安装 Microsoft Office。
阅读全文
相关推荐












