Editing the target or multiple hyperlinks

L

LWhite

I have a large group of files that will all exist in a single folder. I want
to open each document. Go through and change every hyperlink by deleting the
first portion of the link. Then save the document, close the document and
move on to the next one in the folder.

What this is doing is changing the hyperlinks from fully qualified to
relative. Let me give this as an example. Every hyperlink in every doc is
the same and looks like this.

http://servername/applicationname/appname.exe/open/docID#

I want them to all go to

/applicationname/appname.exe/open/docid#

Each Document ID number is unique. The portion to remove is acutally 33
characters. This will allow for users on different servers to view the
documents without authenticating to another server.

Thanks for all of your help.
LWhite
 
J

Jonathan West

LWhite said:
I have a large group of files that will all exist in a single folder. I
want
to open each document. Go through and change every hyperlink by deleting
the
first portion of the link. Then save the document, close the document and
move on to the next one in the folder.

What this is doing is changing the hyperlinks from fully qualified to
relative. Let me give this as an example. Every hyperlink in every doc is
the same and looks like this.

http://servername/applicationname/appname.exe/open/docID#

I want them to all go to

/applicationname/appname.exe/open/docid#

Each Document ID number is unique. The portion to remove is acutally 33
characters. This will allow for users on different servers to view the
documents without authenticating to another server.

A document has a Hyperlinks collection, of all the Hyperlink objects in the
document. A Hyperlink object has an Address property and a Subaddress
property. The Address is the portion to the left of the # and the Subaddress
is the portion to the right. A link to another location in the same document
will have a blank Address. A link to the start of another document will have
a blank Subaddress.

You can both read and write the Address property of a Hyperlink object. So
what you need to do is cycle through the Hyperlinks using a For Each-Next
loop, read the address, change it as necessary and write it back. Write some
code that does that on a single document. Then put the code into the inner
loop of the macro shown in article below in order to make a batch process of
it, replacing the find/replace code that is already there.

Find & ReplaceAll on a batch of documents in the same folder
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm
 

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