Converting hyperlinks to plain text

S

Sesquipedalian Sam

Is there a way to convert only hyperlinks to plain text without
affecting other fields (such as page numbers, dates, etc.)?

Searching the archives, I found suggestions to use both Ctrl+Shift+F9
and also Ctrl+6. On my Word 2007 system, they seem to do the same
thing. They both convert all fields. Is there a difference?
 
L

Lene Fredborg

You can use the following macro:

Sub Hyperlinks_UnlinkAll()

Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldHyperlink Then
oField.Unlink
End If
Next oField

End Sub

For help on installing a macro, see:
http://www.gmayor.com/installing_macro.htm

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Graham Mayor

There is no difference between the two keyboard shortcuts. They are merely
alternatives.

The approach to hyperlinks depends on what you want to achieve. If you don't
want hyperlinks in your document, then you could start by not inserting them
in the first place.
or
Turn off the autoformat as you type option to convert web and e-mail
addresses to hyperlinks
or
If you merely want to avoid the coloured formatting, change the Hyperlink
and Followed Hyperlink styles to match the underlying text.
or
If you really want to convert only Hyperlinks to text in one operation then
you can do that with a macro

Sub HyperlinksToText()
Dim oRng As Range
Dim iFld As Long
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldHyperlink Then
.Unlink
End If
End With
Next iFld
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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