Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2016, 10:05 AM
dan88 dan88 is offline Convert Hyperlinks to ahref Windows 10 Convert Hyperlinks to ahref Office 2016
Novice
Convert Hyperlinks to ahref
 
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
  #2  
Old 05-09-2016, 03:57 PM
macropod's Avatar
macropod macropod is offline Convert Hyperlinks to ahref Windows 7 64bit Convert Hyperlinks to ahref Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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:
Code:
Sub HyperlinkToHRef()
Application.ScreenUpdating = False
With ActiveDocument
  While .Hyperlinks.Count > 0
    With .Hyperlinks(1)
      .Range.InsertAfter "<a href=""" & .Address & """>" & .TextToDisplay & "</a>"
      .Range.Delete
    End With
  Wend
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-09-2016, 06:19 PM
dan88 dan88 is offline Convert Hyperlinks to ahref Windows 10 Convert Hyperlinks to ahref Office 2016
Novice
Convert Hyperlinks to ahref
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default

Paul,

you are a genius!!!!!


Thank you so much - I was having to manually fix these scattered throughout the document.

Saved me from this tedious job of finding the hyperlinks then fixing them

Much gratitude

dan
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Hyperlinks to ahref Convert html links into embedded hyperlinks njcloud Mail Merge 23 02-04-2020 02:00 PM
Word 2013's "File > Convert" only partly converts some Hyperlinks RichardDavey Word 0 05-27-2015 10:37 AM
Hyperlinks in PP ArtemMetr PowerPoint 2 03-20-2015 01:57 AM
Convert Hyperlinks to ahref PDF hyperlinks banccard Word 1 12-22-2011 08:45 PM
hyperlinks forrestgump Word 0 12-30-2010 04:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft