Jonathan
Thu Oct 11 08:06:51 PDT 2007
"LWhite" <LWhite@discussions.microsoft.com> wrote in message
news:A80A6BF3-2DF4-4C62-A515-D192368308DC@microsoft.com...
>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
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup