如何使用 Python 从 PowerPoint 演示文稿幻灯片中提取评论
How to extract comments from PowerPoint presentation slides using Python
我需要从一系列 PowerPoint 演示文稿中提取评论(使用 Microsoft PowerPoint 评论功能制作)。
以下 link 解释了如何在 C# 中执行此操作:
python-pptx 似乎没有 read/write 来自 PowerPoint 的评论的功能:
https://python-pptx.readthedocs.io/en/latest/
如果存在这样的功能,我在上面的文档中找不到。
有什么办法吗?
参考此 ,在 python-pptx
中尚无法与 PowerPoint 中的评论进行交互。
不过,您可以通过他们的 ReadTheDocs 页面将其作为一项功能来请求。他们建议您通过邮件列表或问题跟踪器联系我们以建议新功能。
我能够通过使用 win32com 访问评论对象并按照 K753 的建议从那里操作它来做到这一点:
import win32com.client
ppt_dir = 'test.pptx'
ppt_app = win32com.client.GetObject(ppt_dir)
for ppt_slide in ppt_app.Slides:
for comment in ppt_slide.Comments:
print(comment.Text)
以下文档包含有关评论对象的更多详细信息:
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.comment
如果您需要回复评论,您可以这样做:
for ppt_slide in ppt_app.Slides:
for comment in ppt_slide.Comments:
print(comment.Text)
for reply in comment.Replies:
print(reply.Text)
我需要从一系列 PowerPoint 演示文稿中提取评论(使用 Microsoft PowerPoint 评论功能制作)。
以下 link 解释了如何在 C# 中执行此操作:
python-pptx 似乎没有 read/write 来自 PowerPoint 的评论的功能:
https://python-pptx.readthedocs.io/en/latest/
如果存在这样的功能,我在上面的文档中找不到。
有什么办法吗?
参考此 python-pptx
中尚无法与 PowerPoint 中的评论进行交互。
不过,您可以通过他们的 ReadTheDocs 页面将其作为一项功能来请求。他们建议您通过邮件列表或问题跟踪器联系我们以建议新功能。
我能够通过使用 win32com 访问评论对象并按照 K753 的建议从那里操作它来做到这一点:
import win32com.client
ppt_dir = 'test.pptx'
ppt_app = win32com.client.GetObject(ppt_dir)
for ppt_slide in ppt_app.Slides:
for comment in ppt_slide.Comments:
print(comment.Text)
以下文档包含有关评论对象的更多详细信息:
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.comment
如果您需要回复评论,您可以这样做:
for ppt_slide in ppt_app.Slides:
for comment in ppt_slide.Comments:
print(comment.Text)
for reply in comment.Replies:
print(reply.Text)