![]() |
|
|
|
#1
|
||||
|
||||
|
Try the following revised code. I've both simplified it and improved its efficiency.
Code:
Sub ConvertHyperlinks()
Dim StrAddr As String, StrDisp As String
' Turn Off Screen Updating
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.Text = "\<[Aa] href=([!\>]@)\>([!\<]@)\</a\>"
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Text = ""
.Forward = True
.MatchWildcards = True
.Wrap = wdFindStop
.Execute
End With
Do While .Find.Found = True
StrAddr = Replace(Split(Split(.Text, ">")(0), "=")(1), Chr(34), "")
StrDisp = Split(Split(.Text, ">")(1), "<")(0)
.Hyperlinks.Add Anchor:=.Duplicate, _
Address:=StrAddr, TextToDisplay:=StrDisp
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
' Restore Screen Updating
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| a href, hyperlink, macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Embedded links
|
spheon | Word | 1 | 06-07-2011 04:11 PM |
| convert html to text at opening | etfjr | Word | 0 | 12-13-2010 11:14 AM |
| Can you actually write HTML and CSS in a word document and send it as an html page | jackaroo | Word | 0 | 07-12-2010 07:49 AM |
| Word with frames, table of contents, and hyperlinks to html | NHMC | Word | 0 | 12-09-2009 12:54 PM |
| Convert a file from HTML to WORD format weblayout view | gtselvam | Word | 0 | 12-02-2008 03:53 AM |