list hyperlink address and subaddress at end of word document

B

buzzard

I found this code in the Word 2000 vba help file that makes a list at
the end of the document of all the addresses of the hyperlinks in the
document

Set myRange = ActiveDocument _
.Range(Start:=ActiveDocument.Content.End - 1)
Count = 0
For Each aHyperlink In ActiveDocument.Hyperlinks
Count = Count + 1
With myRange
'.InsertAfter "Hyperlink #" & Count & vbTab
.InsertAfter aHyperlink.Address
.InsertParagraphAfter
End With
Next aHyperlink

I"ve been using this without problems, but I need to be able to tweak
it so that it lists not only the hyperlink address but also the
subaddress. I don't really understand VBA very well, but so far I've
been able to figure out a way to get stuff done with it. Part of the
fun is being able to figure it out for yourself, but in this case, I
just haven't been able to figure this out even after a couple of hours
of searching the Internet. .
 
J

Jay Freedman

I found this code in the Word 2000 vba help file that makes a list at
the end of the document of all the addresses of the hyperlinks in the
document

Set myRange = ActiveDocument _
.Range(Start:=ActiveDocument.Content.End - 1)
Count = 0
For Each aHyperlink In ActiveDocument.Hyperlinks
Count = Count + 1
With myRange
'.InsertAfter "Hyperlink #" & Count & vbTab
.InsertAfter aHyperlink.Address
.InsertParagraphAfter
End With
Next aHyperlink

I"ve been using this without problems, but I need to be able to tweak
it so that it lists not only the hyperlink address but also the
subaddress. I don't really understand VBA very well, but so far I've
been able to figure out a way to get stuff done with it. Part of the
fun is being able to figure it out for yourself, but in this case, I
just haven't been able to figure this out even after a couple of hours
of searching the Internet. .

Change the part that inserts the text to this:

With myRange
'.InsertAfter "Hyperlink #" & Count & vbTab
.InsertAfter aHyperlink.Address & vbTab
.InsertAfter aHyperlink.SubAddress
.InsertParagraphAfter
End With

The added '& vbTab' after aHyperlink.Address inserts a tab character
between the address and the subaddress; then the next line inserts the
subaddress.
 
B

buzzard

On Sun, 16 May 2010 15:14:52 -0700 (PDT), buzzard
Change the part that inserts the text to this:

    With myRange
        '.InsertAfter "Hyperlink #" & Count & vbTab
        .InsertAfter aHyperlink.Address & vbTab
        .InsertAfter aHyperlink.SubAddress
        .InsertParagraphAfter
    End With

The added '& vbTab' after aHyperlink.Address inserts a tab character
between the address and the subaddress; then the next line inserts the
subaddress.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroupso all may benefit.

Thanks! I knew it had to be pretty straightforward.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top