replace text with hyperling

D

Dan Irwin

in word 2002 is there anyway to covert every instance of a word in to
a hyperlink?

for example:
i want to replace every time my report says webpage with the word
webpage, but you can now click on the word and go to www.cisco.com
 
H

Hilary Ostrov

On 14 Dec 2003 14:14:10 -0800, in
in word 2002 is there anyway to covert every instance of a word in to
a hyperlink?

for example:
i want to replace every time my report says webpage with the word
webpage, but you can now click on the word and go to www.cisco.com

Dan, probably the easiest way is to create a macro. If you don't know
how to Record a macro ... Select Tools->Macro->Record new macro. At
the prompt, replace "Macro1" with "web" (without the quotes). Click
the Keyboard button. Assign ALT+W (assuming it's currently unassigned
or choose ALT+ another letter) Close. Then close the Macro recording
bar (which looks more like a box than a bar!) that appears on your
screen. Next, select Tools->Macro->Macros. Select "web", then Edit.
Replace everything from

Sub web()

to

End Sub

with:


Sub web()
'
' web Macro
' Macro to find the word "webpage" and make it a hyperlink
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "webpage"
.Replacement.Text = "<a
href=""http://www.cisco.com/>webpage</a>"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.cisco.com/", SubAddress:="", ScreenTip:="",
TextToDisplay:= _
"webpage"
End Sub

Close the Visual Basic window and return to your document. Then just
hit ALT+W until you've converted each instance of "webpage" to a
hyperlink.

HTH

hro
 
H

Hilary Ostrov

On 14 Dec 2003 20:26:40 -0800, in
thanks for your help it worked, i was wondering if you could help me
with another post also,
http://groups.google.com/[email protected]&rnum=2

Glad I was able to help! As for the MS Script Editor, from everything
I've read, it appears to be an adjunct to FrontPage, and also appears
in the Web Tools toolbar, so it is for html coding. See:

http://www.microsoftfrontpage.com/content/TipsAndTricks/FP2002/68_MicrosoftScriptEditor.htm

I doubt very much that it will help you with Word, where the
underlying code is VB. FWIW, for html, I prefer HomeSite.

hro
 
D

Dan Irwin

Hilary Ostrov said:
On 14 Dec 2003 20:26:40 -0800, in


Glad I was able to help! As for the MS Script Editor, from everything
I've read, it appears to be an adjunct to FrontPage, and also appears
in the Web Tools toolbar, so it is for html coding. See:

http://www.microsoftfrontpage.com/content/TipsAndTricks/FP2002/68_MicrosoftScriptEditor.htm

I doubt very much that it will help you with Word, where the
underlying code is VB. FWIW, for html, I prefer HomeSite.

thank verry much for the site, now for one final question how would i
change the macro to convert a word to a link to a bookmark either in
the same document or a bookmark in a diffrent document?
 
H

Hilary Ostrov

On 16 Dec 2003 10:07:12 -0800, in
(e-mail address removed) (Dan Irwin) wrote:

[...]
thank verry much for the site, now for one final question how would i
change the macro to convert a word to a link to a bookmark either in
the same document or a bookmark in a diffrent document?

I think you mentioned that you are a programmer, so you should have no
trouble editing the original macro code [ALT+F8->Edit] and where
appropriate replacing the text you are searching for and the hyperlink
to reflect your newtext and (bookmarkname (in same document)) or
(path\filename and bookmarkname (in a different document)) .
Hyperlink for bookmarkname in the same doc. is prefaced with \l but in
a different document is noted as SubAddress.

Alternatively, you can record one or more new macros, see:

http://www.mvps.org/word/FAQs/MacrosVBA/UsingRecorder.htm

and edit accordingly. This will help you learn for the future!

hro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top