View Single Post
 
Old 02-16-2018, 02:07 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,339
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

Quote:
Originally Posted by poetofpiano View Post
your version only copied the name of the bookmark instead of the full file path
That suggests the actual hyperlink lacked the enclosing double quotes. You also hadn't mentioned wanting to get the hyperlink sub-address (i.e. the bookmark). In that case, try:
Code:
Sub CopyHyperlink()
Dim Rng As Range
With Selection.Hyperlinks(1).Range.Fields(1)
  Set Rng = .Code
  With .Code
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Format = False
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = False
      .Text = "\l"
      .Replacement.Text = "#"
      .Execute Replace:=wdReplaceAll
      .Text = "HYPERLINK"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
      .Text = "^w"
      .Execute Replace:=wdReplaceAll
      .Text = Chr(34)
      .Execute Replace:=wdReplaceAll
    End With
  End With
End With
Rng.Copy
While InStr(Rng.Text, "HYPERLINK") = 0
  Undo
Wend
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote