How to extract comments from PowerPoint presentation slides using Python
Question:
I need to extract comments (made using the Microsoft PowerPoint comment feature) from a series of PowerPoint presentations.
The following link explains how to do it in C#:
It appears that python-pptx does not have the functionality to read/write comments from PowerPoint:
https://python-pptx.readthedocs.io/en/latest/
If such a feature exists, I can not find it in the documentation above.
Is there any way to do this?
Answers:
Referring to this thread, interacting with comments in PowerPoint is not yet possible in python-pptx
.
You may be able to request it as a feature through their ReadTheDocs page, though. They recommend that you reach out via the mailing list or issue tracker to suggest a new feature.
I was able to do this by using win32com to access the comment object and manipulate it from there as suggest by 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)
The following documentation has further details on the comment object:
https://learn.microsoft.com/en-us/office/vba/api/powerpoint.comment
And if you need replies to comments you can do this:
for ppt_slide in ppt_app.Slides:
for comment in ppt_slide.Comments:
print(comment.Text)
for reply in comment.Replies:
print(reply.Text)
I need to extract comments (made using the Microsoft PowerPoint comment feature) from a series of PowerPoint presentations.
The following link explains how to do it in C#:
It appears that python-pptx does not have the functionality to read/write comments from PowerPoint:
https://python-pptx.readthedocs.io/en/latest/
If such a feature exists, I can not find it in the documentation above.
Is there any way to do this?
Referring to this thread, interacting with comments in PowerPoint is not yet possible in python-pptx
.
You may be able to request it as a feature through their ReadTheDocs page, though. They recommend that you reach out via the mailing list or issue tracker to suggest a new feature.
I was able to do this by using win32com to access the comment object and manipulate it from there as suggest by 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)
The following documentation has further details on the comment object:
https://learn.microsoft.com/en-us/office/vba/api/powerpoint.comment
And if you need replies to comments you can do this:
for ppt_slide in ppt_app.Slides:
for comment in ppt_slide.Comments:
print(comment.Text)
for reply in comment.Replies:
print(reply.Text)