Word and hyperlink global replace problem
Word and hyperlink global replace problem
Author
Discussion

rodney59

Original Poster:

424 posts

278 months

Thursday 23rd February 2006
quotequote all
I have a Word 2000 document with hyperlinks in a table. (about 500 links).
All the links have the IP address. However the server has now changed IP address and I should have been using the DNS name really.

I am having problems changing the hyperlinks automatically.

If I do a search and replace all then all that is changed is the text that is displayed in the table not the hyperlink behind the text.
If I right click the hyperlink and "toggle field codes" I see that the link has not changed.
In this state if I now search and replace it does replace the hyperlink. However I then have to do "update field" (right click on hyperlink) for the new hyperlink to be active.

Is there a way I can globally change all the hyperlinks? (from 123.123.123.123 to companyname)?

many thanks

embrolium

196 posts

267 months

Thursday 23rd February 2006
quotequote all
Have you tried updating your hosts file so that the old ip address points to the new domain name?

rodney59

Original Poster:

424 posts

278 months

Thursday 23rd February 2006
quotequote all
Would work, but as the doc goes worldwide, it needs the DNS name in the link now.
I cant expect everybody to add an entry in their hosts file just because I was an idiot and used the IP address directly.

jamieboy

5,929 posts

259 months

Thursday 23rd February 2006
quotequote all
Not sure of the exact syntax, but I think you could do it as a macro using VBA. Pseudo-code something like:

for each oLink in activedocument.hyperlinks
oLink.address = replace(oLink.address,'ipaddress','hostname')
next

Someone will probably be along shortly with a better solution, but try a bit of light googling around VBA and hyperlinks.

edit to add better detail


>> Edited by jamieboy on Thursday 23 February 13:08

zumbruk

7,848 posts

290 months

Thursday 23rd February 2006
quotequote all
Save the file in RTF, rename it to .txt, edit the URLs, rename it to .rtf and reload it into Word.

[Later]Except that I can't get it to work - Word shows the old url after changing it like this.

rodney59

Original Poster:

424 posts

278 months

Thursday 23rd February 2006
quotequote all
cheers works for me
global replace will fix the text you can see and the method you said will fix the url I cant.

job done!

Many thanks...

GreenV8S

31,024 posts

314 months

Thursday 23rd February 2006
quotequote all
Globally show codes, do the search and replace, select all and F9 to update all fields.

zumbruk

7,848 posts

290 months

Thursday 23rd February 2006
quotequote all
rodney59 said:
cheers works for me
global replace will fix the text you can see and the method you said will fix the url I cant.

job done!

Many thanks...


Blimey, I fixed something in Windows!


Jnr

483 posts

281 months

Thursday 23rd February 2006
quotequote all
ooooh, this looks interesting.

Is it possible to do something like this in an excel file?


J

rodney59

Original Poster:

424 posts

278 months

Thursday 23rd February 2006
quotequote all
Jnr said:
ooooh, this looks interesting.
Is it possible to do something like this in an excel file?
J

My excel doesnt support rft. (as rtf is rich text format) and using csv you cant. Excel saves the hyperlink and not the text for it, however when loading the csv back in, Excel does not see it as a hyperlink, just text.

jamieboy

5,929 posts

259 months

Thursday 23rd February 2006
quotequote all
Jnr said:
ooooh, this looks interesting.
Is it possible to do something like this in an excel file?
J
If you mean the VBA stuff, then yes. Anything* you can do through the GUI in Excel, you can automate through VBA. There's loads of examples on MSDN - if you work with any sort of complicated MS Office documents at all, then it's well worth poking about and seeing what's possible.


*OK, I'm sure there are some things you can't do, but you get the idea.