


The Replacement object represents the replace criteria for a find and replace operation. The following example performs the same result as the previous example, using arguments of the Execute method. If the find operation is successful, the range is redefined and bold formatting is applied to the word "blue." With The following example locates the first occurrence of the word "blue" in the active document. If the Find object is accessed from a Range object, the selection is not changed but the Range is redefined when the find criteria is found. FindText:="Hello", _įinding text without changing the selection You can set the individual properties of the Find object or use arguments with the Execute method, as shown in the following example.

The Find object includes properties that relate to the options in the Find and Replace dialog box. The following example selects the next occurrence of the word "Hello." If the end of the document is reached before the word "Hello" is found, the search is stopped. If the Find object is accessed from the Selection object, the selection is changed when the find criteria is found. The find action differs slightly depending upon whether you access the Find object from the Selection object or the Range object. The Find object is available from the Selection object and the Range object.

Set wdDoc = ("C:\Users\OPP PC 2016\Dropbox\jobb\Visual Basic\wordtest.Finding and replacing is exposed by the Find and Replacement objects. Set wdApp = CreateObject("word.application") I suspect the problem is 2), which is why I ask for help here. The reference is needed, in which case I do not understand how to proceed? I use Win/Office 365 with a continuously updated Office pack. The reference does not matter and I have messed up the code.Ģ. Switching off the latter two does not help the error message still exists.ġ. The libraries I have activated are: VBA for Appliations, Excel 16.0 Object Library (these two I am not allowed to switch off), Office 16.0 Object Library and OLE Automation. However - here I run into a message saying that the name is in conflict with "existing module, project or object library". However, I can only find the text, and fill the replace dialogue box - it does not do the actual replacing.Īfter searching, it seems the problem is that I need to add Microsoft Word 16.0 Object Library in my reference section in my VBA. This should be plain sailing, multiple solutions exist online. I want to search/replace text in a Word doc from Excel. Have searched a lot to find a solution, hope some can verify what my problem is and how to solve it.
