View Single Post
 
Old 10-26-2014, 04:34 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Links to URLs don't use Mergefields as your code suggests - they use Hyperlinks. Accordingly, you could use a macro like the following to loop through all hyperlinks in a document so you can change (or not) the display text:
Code:
Sub Demo()
Dim HLnk As Hyperlink
For Each HLnk In ActiveDocument.Hyperlinks
  With HLnk
    .Range.Select
    Select Case InputBox("Please input the code for the text to display:" & _
      vbCr & vbTab & "1. 'Print Item'" & _
      vbCr & vbTab & "2. 'Text Link'" & _
      vbCr & vbTab & "3. URL", "Update Display Text", "3")
    Case 1: .TextToDisplay = "Print Item"
    Case 2: .TextToDisplay = "Text Link"
    Case Else: .TextToDisplay = .Address
    End Select
  End With
Next
End Sub
An alternative would be to have separate macros for each kind of conversion you want to do, so you can assign each to a different keyboard shortcut. The drawback is that you'd have to manually select each link before changing it.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote