View Single Post
 
Old 01-03-2017, 01:28 AM
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

Fields created by Word itself usually have a space inside each of the field braces. That space isn't necessary, so field codes constructed programmatically may lack them. Fields created manually may even have more of these inconsequential spaces. That said, it's not apparent why you're not using the various Field methods that are available to you, with which it doesn't really matter whether the extra spaces are there. For example:
MsgBox Trim(ActiveDocument.Hyperlinks(1).Range.Fields(1). Code.Text)
will always return the field code without any superfluous leading/trailing spaces. Similarly, for the different hyperlink elements, you might use any one or more of:
Code:
With ActiveDocument.Hyperlinks(1)
  MsgBox "Address: " & .Address & vbCr & _
  "Sub-Address: " & .SubAddress & vbCr & _
  "Text To Display: " & .TextToDisplay & vbCr & _
  "Screen Tip: " & .ScreenTip & vbCr & _
  "Target: " & .Target
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote