Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlinks in Word cut at #

Status
Not open for further replies.
The rest is in subaddress.

Code:
Sub test()
Dim wdDoc As Word.Document
Dim oLink As Word.Hyperlink

Set wdDoc = ThisDocument
Set oLink = wdDoc.Hyperlinks(1)
1 Debug.Print oLink.Address & "#" & oLink.SubAddress
2 Debug.Print oLink.TextToDisplay
3 Debug.Print oLink.Name
End Sub

In (1): I guessed the '#' sign.
In (2): the code displays the text on the screen, to get proper address it has to be displayed.
In (3): '#' is replaced by ' - '.
 
Thanks combo,

I found this code:
Code:
If hyperlink.SubAddress <> "" Then
    strUrl = hyperlink.Address & "#" & hyperlink.SubAddress
End If
It's time to test it...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top