Skip to content

Accessing Comments #792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TylerReedMC opened this issue Mar 11, 2020 · 2 comments
Closed

Accessing Comments #792

TylerReedMC opened this issue Mar 11, 2020 · 2 comments

Comments

@TylerReedMC
Copy link

I've read the docs and perused the API but can't find any way to access comments in a document. For example, if you highlight some text in Word and add a comment for that text. Are comments exposed by python-docx?

@jlovegren0
Copy link

jlovegren0 commented Apr 4, 2020

There's no API support for it, not any support at all except to access the raw xml. The very basic structures are there to load it, and the package has plenty of general purpose XML parsing sugar, so it wouldn't be a big stretch to add support in the future. Here is how to get the XML:

from docx import Document
from docx.opc.constants import RELATIONSHIP_TYPE as RT
p = Document('myfile_with_comments.docx')
cpart = p.part.part_related_by(RT.COMMENTS)
xmlString = cpart.blob
print(xmlString)

@scanny
Copy link
Contributor

scanny commented Apr 5, 2020

Closing in favor of #93

@scanny scanny closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants