Changing Multiple Hyperlinks in Word 2007

M

macropod

Hi dblee50,

My bad, sorry.

Contrary to what I remembered, the code changes the display text too. I'll have to fix that - and make it compatible with Office
2007.

--
Cheers
macropod
[Microsoft MVP - Word]


Hi dblee50,

The link I pointed you to has a utility for making the change. It changes only the (hyper)links - not the filenames or the
hyperlink
display text.

--
Cheers
macropod
[Microsoft MVP - Word]


No, I said
In the macro that I sent to you, change the line
If alink.Type = wdFieldLink Then

If alink.Type = wdFieldHyperlink Then
Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
Did you try using the macro that I sent to you with Link changed to
Hyperlink?
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Hi dblee50,
The code Doug and I provided was for changing the actual hyperlink, not
the display text - you didn't ask about that. Generally
speaking, the better practice is to make the display text something
more
meaningful than just a URL.
--
Cheers
macropod
[Microsoft MVP - Word]
message
On Dec 15, 1:35 pm, "Doug Robbins - Word MVP"
If you press Alt+F9 to toggle on the display of the fields in the
document,
what type of fields are they?
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

On Dec 15, 3:58 am, "Doug Robbins - Word MVP"
Did you get the macro installed?
If not, see the article "What do I do with macros sent to me by
other
newsgroup readers to help me out?"
at:http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself
of
my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

On Dec 14, 1:33 pm, "Doug Robbins - Word MVP"
Try using the following.
' Macro created 26/10/01 by Doug Robbins to update links in a
document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer,
linkcode
As
Range
Dim Message, Title, Default, Newfile
Dim counter As Integer
counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then
Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Message = "Enter the modified path and filename following
this
Format " & linkfile
Title = "Update Link"
Default = linkfile
Newfile = InputBox(Message, Title, Default)
End If
linkcode.Text = linktype & Newfile & linklocation
counter = counter + 1
End If
Next alink
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail
yourself
of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

I have a large document with tables that list a 3 or 4
digit
code
that
refers to an equipment item. In years past, I created
hyperlinks
that, when clicked on, take the viewer to a picture of that
item.
The
pictures are located in another folder but in the same
folder
as the
large document, ie. E:\large.doc and E:\Pictures\0001.jpg.
Worked
fine until this year. Now when clicked on the link it can't
find
the
pictures cause the reference is wrong. When I hover over
the
link,
it
reads something like, /Documents and
Settings/b1111111/Application
Data/Microsoft/Word/Pictures/0001.jpg. If I right click on
the link
and edit, I can change it and all works ok, it's just that
I
have a
thousand links and I would really like to automate this.
Nothing I
have tried has worked and I just don't know enough about
VBA
to
program this.When I use Alt+F9 I could change multiple
links,
but
when
I went back to the normal view it would not change the link
info.
Short of manually updating each link, can anybody help?
thanks
Thanks, but no luck. I couldn't get the Doug Robbins macro to
do
anything (probably didn't know how to do it) and macropod's
fieldlink
updater I couldn't figure out either. thanks for the attempt,
but I
don't have any experience with macros other than recording and
running.
Thanks again. I did copy and paste macro in as your attachment
instructed. I had done the same before. This time I watched the
step
by step and when it gets to the line "If alink.Type = wdFieldLink
Then" it jumps to "End If" and then "Next alink" and repeats
without
anything else happening. It doesn't look as though I can attach a
test doc to show what I have and what I trying to do, but it is
simply
a word document with a table that has a column with four digit
numbers
that I have previously hyperlinked to another folder in the same
folder as the original doc. .
It shows hyperlink. This seems strange and is why just changing this
part when the (HYPERLINK "SE%20Master%20Pictures/2272.jpg") is shown.
If I Alt-F9 back to normal view where the blue underlined 2272 is
shown and hover over the link, it shows file:///C:\Documents and
Settings\myuserID\Application Data\Microsoft\Word\SE Master Pictures
\2272.jpg
That is, if Alt-=F9 and change the info, then change back, nothing
seems to change when hovering over link and it doesn't work.
I've tried to go to Alt-F9 to display hyperlink path and change it. I
then update that field (F9) and try it to no avail. It still shows
the old path when hovering over the link.
Sorry, I may have not been clear in previous post. I do not want to
change the display text, if the display text is what you see in the
document when reading. It is correct. Foe example, when I look at a
cell in the table that has this link, I see a number, ie. 2272. That
number is a hyperlink. That's what it should look like. If I place
my cursor over this number it reveals the path, ie. file:///C:\Documents
and Settings\myuserID\Application Data\Microsoft\Word\SE Master
Pictures\2272.jpg. But if I use Alt-F9 it shows the

...

read more »

macropod, I've tried your macro just about every option and get an in
some instances it does change the link the way I need, it's just that
it also changes the viewed hyperlink (what you see when you read
document) from ie. 2272 to the full path making that a link,
ie.file///e:/...2272.jpg. This part is undesirable but I can' t
figure out how to keep the original intact.
 
D

dblee50

Hi dblee50,

My bad, sorry.

Contrary to what I remembered, the code changes the display text too. I'll have to fix that - and make it compatible with Office
2007.

--
Cheers
macropod
[Microsoft MVP - Word]


Hi dblee50,
The link I pointed you to has a utility for making the change. It changes only the (hyper)links - not the filenames or the
hyperlink
display text.
No, I said
In the macro that I sent to you, change the line
If alink.Type = wdFieldLink Then
to
If alink.Type = wdFieldHyperlink Then
--
Hope this helps,
Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
On Dec 16, 1:42 pm, "Doug Robbins - Word MVP"
Did you try using the macro that I sent to you with Link changed to
Hyperlink?
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Hi dblee50,
The code Doug and I provided was for changing the actual hyperlink, not
the display text - you didn't ask about that. Generally
speaking, the better practice is to make the display text something
more
meaningful than just a URL.
--
Cheers
macropod
[Microsoft MVP - Word]
message
On Dec 15, 1:35 pm, "Doug Robbins - Word MVP"
If you press Alt+F9 to toggle on the display of the fields in the
document,
what type of fields are they?
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

On Dec 15, 3:58 am, "Doug Robbins - Word MVP"
Did you get the macro installed?
If not, see the article "What do I do with macros sent tome by
other
newsgroup readers to help me out?"
at:http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself
of
my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

On Dec 14, 1:33 pm, "Doug Robbins - Word MVP"
Try using the following.
' Macro created 26/10/01 by Doug Robbins to update links in a
document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer,
linkcode
As
Range
Dim Message, Title, Default, Newfile
Dim counter As Integer
counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then
Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Message = "Enter the modified path and filename following
this
Format " & linkfile
Title = "Update Link"
Default = linkfile
Newfile = InputBox(Message, Title, Default)
End If
linkcode.Text = linktype & Newfile & linklocation
counter = counter + 1
End If
Next alink
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail
yourself
of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

I have a large document with tables that list a 3 or4
digit
code
that
refers to an equipment item. In years past, I created
hyperlinks
that, when clicked on, take the viewer to a picture of that
item.
The
pictures are located in another folder but in the same
folder
as the
large document, ie. E:\large.doc and E:\Pictures\0001.jpg.
Worked
fine until this year. Now when clicked on the link it can't
find
the
pictures cause the reference is wrong. When I hover over
the
link,
it
reads something like, /Documents and
Settings/b1111111/Application
Data/Microsoft/Word/Pictures/0001.jpg. If I right click on
the link
and edit, I can change it and all works ok, it's just that
I
have a
thousand links and I would really like to automate this.
Nothing I
have tried has worked and I just don't know enough about
VBA
to
program this.When I use Alt+F9 I could change multiple
links,
but
when
I went back to the normal view it would not change the link
info.
Short of manually updating each link, can anybody help?
thanks
Thanks, but no luck. I couldn't get the Doug Robbins macro to
do
anything (probably didn't know how to do it) and macropod's
fieldlink
updater I couldn't figure out either. thanks for the attempt,
but I
don't have any experience with macros other than recording and
running.
Thanks again. I did copy and paste macro in as your attachment
instructed. I had done the same before. This time I watched the
step
by step and when it gets to the line "If alink.Type = wdFieldLink
Then" it jumps to "End If" and then "Next alink" and repeats
without
anything else happening. It doesn't look as though I can attach a
test doc to show what I have and what I trying to do, but it is
simply
a word document with a table that has a column with four digit
numbers
that I have previously hyperlinked to another folder in the same
folder as the original doc. .
It shows hyperlink. This seems strange and is why just changing this
part when the (HYPERLINK "SE%20Master%20Pictures/2272.jpg") isshown.
If I Alt-F9 back to normal view where the blue underlined 2272is
shown and hover over the link, it shows file:///C:\Documents and
Settings\myuserID\Application Data\Microsoft\Word\SE Master Pictures
\2272.jpg
That is, if Alt-=F9 and change the info, then change back, nothing
seems to change when hovering over link and it doesn't

...

read more »

no problem. Thanks for trying.
 
D

dblee50

Maybe the code I posted was created for some other purpose.  Maybe you can
just use Ctrl+F9 to reveal the codes and then copy and paste the part that
needs to be changed into the find what control of the Edit>Replace dialog
and then enter the required replacement into the Replace with Control and
then click on Replace All.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my serviceson
a paid professional basis.


No, I said
In the macro that I sent to you, change the line
If alink.Type = wdFieldLink Then

If alink.Type = wdFieldHyperlink Then
Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to obtain my services
on
a paid professional basis.
Did you try using the macro that I sent to you with Link changed to
Hyperlink?
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Hi dblee50,
The code Doug and I provided was for changing the actual hyperlink,
not
the display text - you didn't ask about that. Generally
speaking, the better practice is to make the display text something
more
meaningful than just a URL.
--
Cheers
macropod
[Microsoft MVP - Word]
message
On Dec 15, 1:35 pm, "Doug Robbins - Word MVP"
If you press Alt+F9 to toggle on the display of the fields in the
document,
what type of fields are they?
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself
of
my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

On Dec 15, 3:58 am, "Doug Robbins - Word MVP"
Did you get the macro installed?
If not, see the article "What do I do with macros sent to me
by
other
newsgroup readers to help me out?"
at:http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail
yourself
of
my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

On Dec 14, 1:33 pm, "Doug Robbins - Word MVP"
Try using the following.
' Macro created 26/10/01 by Doug Robbins to update linksin
a
document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer,
linkcode
As
Range
Dim Message, Title, Default, Newfile
Dim counter As Integer
counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then
Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Message = "Enter the modified path and filename following
this
Format " & linkfile
Title = "Update Link"
Default = linkfile
Newfile = InputBox(Message, Title, Default)
End If
linkcode.Text = linktype & Newfile & linklocation
counter = counter + 1
End If
Next alink
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail
yourself
of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com

I have a large document with tables that list a 3 or 4
digit
code
that
refers to an equipment item. In years past, I created
hyperlinks
that, when clicked on, take the viewer to a picture of
that
item.
The
pictures are located in another folder but in the same
folder
as the
large document, ie. E:\large.doc and
E:\Pictures\0001.jpg.
Worked
fine until this year. Now when clicked on the link it
can't
find
the
pictures cause the reference is wrong. When I hover over
the
link,
it
reads something like, /Documents and
Settings/b1111111/Application
Data/Microsoft/Word/Pictures/0001.jpg. If I right click
on
the link
and edit, I can change it and all works ok, it's just
that
I
have a
thousand links and I would really like to automate this.
Nothing I
have tried has worked and I just don't know enough about
VBA
to
program this.When I use Alt+F9 I could change multiple
links,
but
when
I went back to the normal view it would not change the
link
info.
Short of manually updating each link, can anybody help?
thanks
Thanks, but no luck. I couldn't get the Doug Robbins macro
to
do
anything (probably didn't know how to do it) and macropod's
fieldlink
updater I couldn't figure out either. thanks for the
attempt,
but I
don't have any experience with macros other than recording
and
running.
Thanks again. I did copy and paste macro in as your attachment
instructed. I had done the same before. This time I watched the
step
by step and when it gets to the line "If alink.Type =
wdFieldLink
Then" it jumps to "End If" and then "Next alink" and repeats
without
anything else happening. It doesn't look as though I can attach
a
test doc to show what I have and what I trying to do, but itis
simply
a word document with a table that has a column with four digit
numbers
that I have previously hyperlinked to another folder in the
same
folder as the original doc. .
It shows hyperlink. This seems strange and is why just changing
this
part when the (HYPERLINK "SE%20Master%20Pictures/2272.jpg") is
shown.
If I Alt-F9 back to normal view where the blue underlined 2272 is
shown and hover over the link, it shows file:///C:\Documents and
Settings\myuserID\Application Data\Microsoft\Word\SE Master
Pictures
\2272.jpg
That is, if Alt-=F9 and change the info, then change back, nothing
seems to change when hovering over link and it doesn't work.
I've tried to go to Alt-F9 to display hyperlink path and change it.. I
then update that field (F9) and try it to no avail. It still shows
the old path when

...

read more »

Well, I had tried that several times but the final solution was to do
open each link and hit F9 to save. It took a while but seems to
work.Thanks for your help.
 

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