Open
Description
Hi
I have managed to return the heading text in a given filename (thank you to the great experts at Stack Overflow) however I cannot return the heading number. Refer to code below. Is there a way to print/return the heading number (list numbering value not heading level).
Thanks
import docx
doc=docx.Document('filename.docx')
def iter_heading(paragraphs):
for paragraph in paragraphs:
if paragraph.style.name('Heading 1'):
yield paragraph
for heading in iter_heading(doc.paragraphs):
print(heading.text)
Metadata
Metadata
Assignees
Labels
No labels