You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
634 B

# pip install pywin32
# https://blog.csdn.net/weixin_42927998/article/details/115086797
import win32com
from win32com.client import Dispatch
docApp = win32com.client.Dispatch('Word.Application')
docApp.Visible = True
docApp.DisplayAlerts = 0
doc = docApp.Documents.Open('c:/1.docx')
# 遍历文档中的所有内嵌形状
for inline_shape in doc.InlineShapes:
if inline_shape.Type == win32com.client.constants.wdInlineShapeChart: # 检查是否为内嵌图表
print("找到一个图表")
# 这里可以对图表进行操作,比如获取图表的类型、数据等
doc.Close()
docApp.Quit()