View Single Post
 
Old 04-18-2014, 03:35 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote