Word help! Converting hyperlinks to endnotes?

I have a 200-page book written in Word 2007. It’s got hyperlinks in it that I need to A) keep in there and B) copy to an endnote. So the end[sup]1[/sup] product will[sup]2[/sup] be something like this.

…last page where the endnotes go…

[sup]1[/sup]http://end.end.end.end.end.end.end.com
[sup]2[/sup]http://will.will.will.will.will.com
The hyperlinks are all over the place right now, in both the footnotes and in the text, and there’s no pattern to them at all.

My biggest hope is that there’s a simple macro that I can run once that will scour the document and do it in one fell swoop. I can get as far manually as alt-F9/find ^dhyperlink and then highlighting everything, so I assume (oh no!) that it can be automated to some extent. If not, even a manual click on each hyperlink would do if I’m careful.

I found a few things that got me close, but I can’t manage to get them to work. Any help or direction?

Oh, did I mention that I’m kinda screwed–book is due by five today and I just noticed that little request. Oh, clients. I love you!

Rhythm~

Here’s a quick macro that I think should work. It doesn’t have any error checking and it will probably add duplicate endnotes if you run it more than once (but you said you needed this fast).

Let me know if something doesn’t work and I can try to help.


Sub HyperlinkToEndnote()
    Dim hl As Hyperlink
    
    For Each hl In ActiveDocument.Hyperlinks
        hl.Range.Select
        Selection.Endnotes.Add Range:=Selection.Range, Reference:=""
        Selection.TypeText Text:=hl.Address
    Next
End Sub

I don’t have anything specific to add, but some basic mastery of VBA really pays off if you’re an industrial Word user. Being able to supplement features with compound constructs for tasks like this can be worth its weight in e-gold.

But yes, the right simple macro like a variation of the above should do it for your. May the MSforce be with you…

Clients.* sigh*

Just noticed you want normal numbering, not roman. Use this:


Sub HyperlinkToEndnote()
    Dim hl As Hyperlink
    
    For Each hl In ActiveDocument.Hyperlinks
        hl.Range.Select
        Selection.EndnoteOptions.NumberStyle = wdNoteNumberStyleArabic
        Selection.Endnotes.Add Range:=Selection.Range, Reference:=""
        Selection.TypeText Text:=hl.Address
    Next
End Sub

And in case you already ran my first attempt, this macro will delete any endnotes so you can recreate them from scratch. Note that it will delete ALL endnotes, so if you had others you want to keep, this will screw you over.


Sub DeleteEndnotes()
    Dim endnt As Endnote
    
    For Each endnt In ActiveDocument.Endnotes
        endnt.Delete
    Next
End Sub

AAAAAAnnnnnnnddddddd THANK YOU!
AB’s spot on with learning VBA. I ended up learnign a lot more SQL in the late 90s or so monkeying then applying what I knew to MS Access. Opened a huge amount of doors, and I never was a ‘real’ programmer. Heck, I wasn’t even an unreal programmer, but it did wonders. I’m okay at some basic things in VBA, but really do need to find the time to focus.

Troutman, I can’t thank you enough. Not for this (er, I guess I could), but about a year ago you responded with one of my favourite macros, one that creates a bookmark. I ended up combining it with another one I’d been using, so now when I rock the mouswheel to the right it adds a highlight to what I’d selected and splits the screen. I can go gallivanting all through the doc, and if I lose my place I just hold alt and flick to the right again and BOOOOOM! It is so incredibly handy. We’re talking hours (literally hours, too, not just those lame metaphoric ones) of time saved over the year and unknowable amounts of frustration and confusion that never took place. Man, that’s one great macro!

Excellent, glad I could help!