I have a grand total of 3 weeks of very part time experience with PythonThis is close as I have gotten with somebody else's code
import win32com.clientdef iter_headings(paragraphs): for paragraph in paragraphs:#The code crashes on the next line!!!!!!!!!!!!!!!!!! if paragraph.Style.Name.startswith('Heading'): yield paragraph# Create a Word application instanceword = win32com.client.Dispatch('Word.Application')# Open the Word documentdocument = word.Documents.Open('d:\\header.docx')# Access paragraphs using the Document objectfor heading in iter_headings(document.Paragraphs): print(heading.Text)# Close the Word document (optional)document.Close()word.Quit()`Any ideas to help would be welcome! I am also using win32com.client to read in the contents of multiple tables in the document and that is working well in another test file, so I would prefer to stick with with win32com if possible.
See the above code.