Click to See Complete Forum and Search --> : Changing a broken hyperlink in a Word doc


homer13j
April 25th, 2006, 01:38 PM
I have a thread on this going at VBforums.com, but I'm hoping someone here may have the answer I'm looking for.

http://www.vbforums.com/showthread.php?t=401235

My company recently took over another and several gigs worth of Word documents were moved to our servers. This broke every hyperlink in another set of docs so my job is to fix them.

The simple solution would be to open the Word doc and go through each hyperlink and change the Address property. Problem is accessing most of the properties of a broken hyperlink causes an error.

I tried reading in all the data using a StreamReader but it only returns the first three chars of the file. Any attempts to manually edit the data prevents the file from opening properly in Word and there are way too many of them to do it this way...

Any ideas? Thanks.

Rich2189
April 25th, 2006, 03:57 PM
Your best bet would be VBA if you have access to it. Something like this.

loop

Open document



dim i%
for i = 1 to ActiveDocument.Hyeperlinks.count
if MsgBox ActiveDocument.Hyeperlinks.Item(1).TextToDisplay = hyperlinkname then
ActiveDocument.Hyperlinks.Item(1).Address = Url
end if
next i



close document

next document

homer13j
April 26th, 2006, 09:34 AM
I didn't try VBA, but if you can't access a broken hyperlink from VB.NET I doubt you could do it from VBA without causing the same error.

We solved the problem by setting up a temporary server with the same name and directory structure of the original server so I can at least access those hyperlinks to change them.

Thanks