3
votes

I would like a macro or method to find and replace instance of a word in a large word document with a hyperlink who's display text is the same as the original word.

Example: I would search for 'project' and replace all instances with a hyperlink www.example.com with the display text remaining 'project'.

I have found many macros that are tantalisingly close but not quite what I need. For example, a macro from this site

How to programmatically edit all hyperlinks in a Word document?

..will change all the hyperlink addresses in a document and their display text. I thought I could change all the instances of 'project' to a hyperlink using inbuilt find and replace, then use that macro to change the display text. However, the inbuilt find and replace function does not create hyperlinks, you have to move the cursor to the unlinked text and press space/enter to activate it. That's not viable in a large document.

To be really persnickety, it would be amazing if it only changed normal body text rather than all text, so I could leave headings and headers unchanged. I imagine this is possible by using the inbuilt find and replace to replace only normal text, then a macro to add the hyperlinks, perhaps.

1
Tried revealing the hyperlink field using shift+F9 then copying the { HYPERLINK/I "...."} thing that appears and inserting that in the replace box of the find and replace tool. Didn't work, just comes up with display text. Tried the method I have described above, replcaing 'project' with www.exaple.com with find and replace function then using macro to edit hyperlink display text. Inbuilt find and replace does not create hyperlinks however. Cheersuser1428171

1 Answers

7
votes

1.Select the hyperlink and press Ctrl+C. This copies the hyperlink to the Clipboard.(might need to create 1 hyperlink to copy)

2.Press Ctrl+H to display the Replace tab of the Find and Replace dialog box.

3.In the Find What box, enter the string/word you want to replace.

4.In the Replace With box, enter ^c.

5.Click Replace All.

not a macro but works. You can record this as a macro then you'll have the macro you are after.

Using the formatting option to select only the formatting style you want to replace.