View Single Post
 
Old 05-09-2016, 10:05 AM
dan88 dan88 is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default Convert Hyperlinks to ahref

Hi all,

I have a hyperlink issue.

My Word doc has all these clickable hyperlinks, I am trying to convert the clickable link into a html link

Example:

Delicious Coffee

Converted to

<a href="http://www.coffee.com/delicious ">Delicious Coffee </a>


Bear Taxonomy

<a href =“http://www.bear.com/bearclassification”> Bear Taxonomy </a>

etc


I only managed to insert the last </a> . The rest I couldn't work out how to do


http://windowssecrets.com/forums/sho...RLs-from-links



Code:
Sub HyperlinkToParagraph1()
Application.ScreenUpdating = False
Dim i As Long, Rng As Range
With ActiveDocument
  For i = .Hyperlinks.Count To 1 Step -1
    With .Hyperlinks(i)
      Set Rng = .Range
      
      'Rng.InsertAfter ": "
      
      'Rng.InsertAfter " <a href = "   ">


      Rng.MoveEndUntil cset 
  
      
      Rng.Collapse wdCollapseEnd
      Rng.FormattedText = .Range.FormattedText
      Rng.Hyperlinks(1).TextToDisplay = .Address
      Rng.InsertAfter "</a>"
      
      .Range.Fields(1).Unlink
    End With
  Next
End With
Application.ScreenUpdating = True

End Sub

Any help appreciated

dan
Reply With Quote