Hello,It seems that when I adjust the text from vba, it erases all the text formatting. I need to be able to find and replace text in a paragraph but I don't want to lose the formatting that is already there (bold, italic, etc.). Also I would like the ability to apply new formatting to the selected text that I just searched for. How do I go about doing this? Do I apply it to the shape.text.story?
Any help would be appreciated.
Thank you.
For find and replace text you can try following code
Sub ReplaceText()Dim txtFIND As String 'The word you want to find and replaceDim txtREPLACE As String 'The new word to replace the oldDim p As PagetxtFIND = InputBox("text you want to find and replace", "Enter text", "")txtREPLACE = InputBox("text that replace old", "Enter text", "")
For Each p In ActiveDocument.Pages 'Loop each page p.TextReplace txtFIND, txtREPLACE, True, FalseNext pEnd Sub