Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding hyperlink in bulk to Word Doc 1

Status
Not open for further replies.

snailface

Technical User
Jan 10, 2007
1
US
I have a line of text that appears numerous times in a word document (approx> 350)

I'd linke this text to act as a hyperlink. Is there a way to do a bulk find/replace that would change this plain text to the hyperlink I need?
 
Have you tried creating the hyperlink once and then copying that into the replace - you might have to check formatting as part of the replace. I haven't tested it, but it is something to try.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Yes, create it once, but you can't copy it into the replace dialog; what you have to do is copy it to the clipboard and then use [blue]^c[/blue] (= clipboard contents) as the replace string.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Nice tip!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
You can do a Copy Hyperlink on an existing hyperlink, but you can not put that into Replace.

You are not being completely clear. Is this the SAME text that is being replaced? Is this different text, but wanting the SAME hyperlink? In other words, different display text, but same target?

There may be a way to trick Replace to do it, but I don't kniow it.

If you are trying the replace the same text throughout the document, with the same hyperlink, then what you CAN do though, is this.

Make one chunks of text have the hyperlink. Say the text is "To Ebay", and the target is "http:\\ebay.com" - and this of course could be anything, including another document, or a bookmark within the document.

Right click the hyperlink you just added, select Copy Hyperlink, then run the following code as a macro. Replace values as needed.
Code:
Sub PasteHyperlink()
Selection.HomeKey Unit:=wdStory
With Selection.Find
   Do While _
   (.Execute(Findtext:="To Ebay", Forward:=True) _
         = True) = True
      Selection.Paste
   Loop
End With
End Sub
It will paste the hyperlink values to all found text ("To Ebay").

This could be expanded to allow variables to the search text. It could also be pumped up to grab the original hyperlink values. There is very possibly a better way (there often is), but I did this as quick and dirty.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top