


Text = “App”: Searches for the text “ App”. Paragraphs(1) means the first paragraph of the word document. With (1).Range.Find: It will start to find the text only in the first paragraph.

Here, book1 is stored as Word application.But, we will do that only for the first paragraph. We will replace the text “ App” with “ Application”. Take look at the following word document: In this example, you will learn to open a word document and replace text from a specific paragraph. VBA to Open a Word Document and Replace Text from Specific Paragraph Read More: How to Replace Text in Excel Formula (7 Easy Ways)ģ. MatchWholeWord = True: It will search this as an entire text not a part of a string.Īs you can see from the result, this VBA code successfully replaced text and changed the formatting of the text in the word document. It will search for the text whether it is in capital or small letter. MatchCase = False: We are not making our search case-sensitive. Forward = True: By setting this to True, we are searching in a forwarding manner. Text = “Smartphone”: This is our replacement text. Font.Bold = True: It will make the font Bold of the replacement text. Text = “Mobile”: Searches for the text “ Mobile”. : it will clear the existing formatting in the Find operation.Now, from the word document, we will replace the text “ Mobile” with “ Smartphone” and also, we will make the text Bold. Replace Text and Change Formatting from a Word Document Read More: Excel VBA: How to Find and Replace Text in Word DocumentĢ. Then, you will see the following result:Īs you can see, our VBA code in Excel worked successfully to open the word document and replace the text. After that, it will open your word document. Execute Replace:=wdReplaceAll: Finally, it will replace all the texts. Wrap = wdFindContinue: It will continue to search till the end of the document. Replacement.Text = “TELEVISION”: Replace the text with “ TELEVISION”. Text = “TV”: Searches for the text “ TV”. Utilizing the WITH statement, we will attempt to avoid the repetition of typing the object name. With : It will start to find the content from the document.Make sure to change the file location according to your device. Documents.Open(“D:\SOFTEKO\List.docm”): it will open your word document.Visible = True: It will make sure that our word document is visible.Here, the book1 is stored as a Word application.
