0

I have found the following VBA code: https://learn.microsoft.com/en-us/office/vba/api/word.find.found.

With Selection.Find 
.ClearFormatting 
.Font.Bold = True 
.Execute FindText:="Hello", Format:=True, Forward:=True 
If .Found = True Then 
.Parent.Expand Unit:=wdParagraph 
.Parent.Copy 
End If 
End With

However I am not sure how to write this in python.

Would anyone be able to help me convert the code to python?

Pav
  • 45
  • 4
  • I think you will find this helpful: https://stackoverflow.com/questions/48088417/selecting-text-between-two-words-from-word-document-using-pywin32 – SnowGroomer Jul 13 '21 at 09:32
  • Whilst not a conversion of your code, here is a link to extracting text from a word document using Python. https://stackoverflow.com/questions/25228106/how-to-extract-text-from-an-existing-docx-file-using-python-docx searching for a specific string should be very straightforward afterwards. – GoodJuJu Jul 13 '21 at 09:47
  • 1
    @SnowGroomer used that method and worked perfectly – Pav Jul 13 '21 at 11:06

0 Answers0