Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
DougM
 
Posts: n/a
Default Can VBA edit hyperlink(s) address

I am moving an Excel spreadsheet with about 3000 hyperlinks from C: drive to
U: drive (servor) and need to revise the hyperlinks accordingly. While I'm at
it, I can take an unneccessary folder (....../folder/....) out of the
address. I tried writing VBA to do this without success. Suggestions? Thank
you in advance. Doug
  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi Doug

I copy this from David McRitchie his site
http://www.mvps.org/dmcritchie/excel/buildtoc.htm#hyp

Sub Fix192Hyperlinks()
Dim OldStr As String, NewStr As String
OldStr = "http://192.168.15.5/"
NewStr = "http://hank.home.on.ca/"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

If you want to fix the display text you can also include .TextToDisplay



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DougM" wrote in message ...
I am moving an Excel spreadsheet with about 3000 hyperlinks from C: drive to
U: drive (servor) and need to revise the hyperlinks accordingly. While I'm at
it, I can take an unneccessary folder (....../folder/....) out of the
address. I tried writing VBA to do this without success. Suggestions? Thank
you in advance. Doug



  #3   Report Post  
DougM
 
Posts: n/a
Default

This is helpful but I think it doesn't solve my problem. Thank you.

It looks like this solution replaces old with new. I need to edit each hyp
the same way (ie c:\target\folder\folder\filename to
u:\target\folder\filename) because each hyp goes to a different file.

Thanks again and in advance. Doug


"Ron de Bruin" wrote:

Hi Doug

I copy this from David McRitchie his site
http://www.mvps.org/dmcritchie/excel/buildtoc.htm#hyp

Sub Fix192Hyperlinks()
Dim OldStr As String, NewStr As String
OldStr = "http://192.168.15.5/"
NewStr = "http://hank.home.on.ca/"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

If you want to fix the display text you can also include .TextToDisplay



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DougM" wrote in message ...
I am moving an Excel spreadsheet with about 3000 hyperlinks from C: drive to
U: drive (servor) and need to revise the hyperlinks accordingly. While I'm at
it, I can take an unneccessary folder (....../folder/....) out of the
address. I tried writing VBA to do this without success. Suggestions? Thank
you in advance. Doug




  #4   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Try it

It use replace to change the path not the file name

--
Regards Ron de Bruin
http://www.rondebruin.nl


"DougM" wrote in message ...
This is helpful but I think it doesn't solve my problem. Thank you.

It looks like this solution replaces old with new. I need to edit each hyp
the same way (ie c:\target\folder\folder\filename to
u:\target\folder\filename) because each hyp goes to a different file.

Thanks again and in advance. Doug


"Ron de Bruin" wrote:

Hi Doug

I copy this from David McRitchie his site
http://www.mvps.org/dmcritchie/excel/buildtoc.htm#hyp

Sub Fix192Hyperlinks()
Dim OldStr As String, NewStr As String
OldStr = "http://192.168.15.5/"
NewStr = "http://hank.home.on.ca/"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

If you want to fix the display text you can also include .TextToDisplay



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DougM" wrote in message ...
I am moving an Excel spreadsheet with about 3000 hyperlinks from C: drive to
U: drive (servor) and need to revise the hyperlinks accordingly. While I'm at
it, I can take an unneccessary folder (....../folder/....) out of the
address. I tried writing VBA to do this without success. Suggestions? Thank
you in advance. Doug






  #5   Report Post  
DougM
 
Posts: n/a
Default

I tried running this without success. Can anybody tell me why?

Sub Fix192Hyperlinks()
'
Dim OldStr As String, NewStr As String
OldStr = "c:\My Templates\Profile Database\"
NewStr = "\\Pinoak\Data\Mfr\Grinding Room\"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

Thank you

"Ron de Bruin" wrote:

Try it

It use replace to change the path not the file name

--
Regards Ron de Bruin
http://www.rondebruin.nl


"DougM" wrote in message ...
This is helpful but I think it doesn't solve my problem. Thank you.

It looks like this solution replaces old with new. I need to edit each hyp
the same way (ie c:\target\folder\folder\filename to
u:\target\folder\filename) because each hyp goes to a different file.

Thanks again and in advance. Doug


"Ron de Bruin" wrote:

Hi Doug

I copy this from David McRitchie his site
http://www.mvps.org/dmcritchie/excel/buildtoc.htm#hyp

Sub Fix192Hyperlinks()
Dim OldStr As String, NewStr As String
OldStr = "http://192.168.15.5/"
NewStr = "http://hank.home.on.ca/"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

If you want to fix the display text you can also include .TextToDisplay



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DougM" wrote in message ...
I am moving an Excel spreadsheet with about 3000 hyperlinks from C: drive to
U: drive (servor) and need to revise the hyperlinks accordingly. While I'm at
it, I can take an unneccessary folder (....../folder/....) out of the
address. I tried writing VBA to do this without success. Suggestions? Thank
you in advance. Doug






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Address List in Excel getalife Excel Discussion (Misc queries) 2 May 29th 06 03:58 PM
Hyperlinks from one document to another document on a different dr Stephen Charts and Charting in Excel 0 January 14th 05 09:05 PM
HOW DO I ENTER TWO NAMES IN ONE ROW FOR ONE ADDRESS FOR LABELS sheilam Excel Discussion (Misc queries) 1 November 30th 04 04:12 PM
Relative Hyperlinks to PDFs (or other documents) || cypher || Excel Discussion (Misc queries) 1 November 30th 04 04:05 AM
Hyperlinks - identifying source in destination sheet UniDave Excel Discussion (Misc queries) 0 November 25th 04 11:07 PM


All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"