walking through all hyperlinks in a word ".doc" or ".rtf" document

L

lbrtchx

I think VBA Object language for Word considers hyperlinks to be
objects, so, there should be a way to programmatically load an array
with and/or replace all hyperlinks in a document
~
This is very useful to consolidate documents. Say you know of a
number of web pages with important embedded content links that you
would like to expand after pasting them on a document for later
reading/studying
~
How could you do that?
~
I searched for an answer and the closer I got was this:
~
// __ microsoft.public.word.docmanagement: "how to delete white
background color of Wikipedia"
Newsgroups: microsoft.public.word.docmanagement
From: "Suzanne S. Barnhill"
Date: Sat, 8 Jul 2006 10:39:42 -0500
Local: Sat, Jul 8 2006 11:39 am
Subject: Re: how to delete white background color of Wikipedia

This Replace operation should do the trick:

1. Press Alt+F9 to toggle field codes so that your hyperlinks are
displaying as { HYPERLINK "http://... }

2. Press Ctrl+H to open the Replace dialog.

3. In the "Find what" box, type "^19 HYPERLINK" (without the
quotation marks).

4. In the "Replace with" box, type "^&" (without the quotation
marks).

5. Click More to expand the dialog. Click back in the "Replace with"
box.

6. Click on Format, then Style. Select "Default Paragraph Font."

7. Replace All.

8. Alt+F9 to toggle back to display of field results.

This will remove the Hyperlink character style, leaving the
hyperlinks still active.
--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

~
Thanks
lbrtchx
 
H

Helmut Weber

Hi,

most of your question is a mystery to me,
nevertheless, this might get you started:

Sub Test67003()
Dim oHpr As Hyperlink
For Each oHpr In ActiveDocument.Hyperlinks
' your code like
' MsgBox oHpr.Range.Fields(1).Code
' MsgBox oHpr.Address
' MsgBox oHpr.SubAddress
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jonathan West

I think VBA Object language for Word considers hyperlinks to be
objects, so, there should be a way to programmatically load an array
with and/or replace all hyperlinks in a document

You can. The Document object has a Hyperlinks collection.
~
This is very useful to consolidate documents. Say you know of a
number of web pages with important embedded content links that you
would like to expand after pasting them on a document for later
reading/studying
~
How could you do that?

I'm not entirely sure what you are asking. Are you wanting to replace all
links with the content of the linked pages?
 

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