python-openxml / python-docx

Create and modify Word documents with Python
MIT License
4.51k stars 1.11k forks source link

How to iterate over each Sentence in Word doc #961

Closed ilcaa72 closed 3 years ago

ilcaa72 commented 3 years ago

i am currently using VBA on Word and would love to switch to python-docx. So i had a question. Within VBA it has a paragraph and sentence object and i can iterate over every sentence like this... Word VBA know what a paragraph, sentence and word and its easy to iterate and make specific changes.....

How can i accomplish this with python-docx? is the Word VBA object model available to me in python-docx? thanks for any insight.

'//  loop over each sentence and word in a Word document (using VBA IDE in MS Word)
Dim s As Range
For Each s In ActiveDocument.Sentences
              s.Select

             for each wrd in s
                      wrd.Select
     next
next
scanny commented 3 years ago

pyDocx is a different package. This repository is for python-docx.

ilcaa72 commented 3 years ago

sorry it was my mistake, (i didnt know the other package existed) i have the right forum and package (ive updated my question)