Skip to content
Advertisement

Python – Send item to next page in Word

I am trying to send text to the next page in a .docx file using Python. So far, I have written a some code that will locate a certain word in a .docx file (using python-docx):

JavaScript

Now I want to send each occurrence of “Hello” to a new page so that each page in my Word document starts with the word “Hello”.

Current Doc: Hello blahblahblahbalh Hello sampletextsampletext

Output:

Hello blahblahblah

New Page

Hello sampletextsampletext

Any help would be appreciated. Thanks.

Advertisement

Answer

This might not look very pretty (or professional) but it gets the job done:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement