Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
ale ale is offline
external usenet poster
 
Posts: 14
Default How do I create a macro to remove path from hyperlink "address"?

Excel 2003
--
May your footsteps be lost in the music of the forest.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How do I create a macro to remove path from hyperlink "address"?

Hi Ale:

It will depend on the form of the hyperlink. For example, if the hyperlinks
look like:

=HYPERLINK("file:///C:\Documents and
Settings\User\Desktop\Book2.xls#Sheet2!B9")

Then a macro like:

Sub path_killer()
For Each r In Selection
v = r.Formula
s = Split(v, "\")
u = UBound(s)
r.Formula = Left(s(0), (Len(s(0)) - 2)) & s(u)
Next
End Sub


will change to the hyperlink to:

=HYPERLINK("file:///Book2.xls#Sheet2!B9")

As you see, the path has been removed.
--
Gary''s Student - gsnu200776


"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.

  #3   Report Post  
Posted to microsoft.public.excel.misc
ale ale is offline
external usenet poster
 
Posts: 14
Default How do I create a macro to remove path from hyperlink "address

Thanks Gary"s Student.

When I ran the macro I copied from your post, it added to the "Text to
display" inst ead of removing the path from the "Address"
--
May your footsteps be lost in the music of the forest.


"Gary''s Student" wrote:

Hi Ale:

It will depend on the form of the hyperlink. For example, if the hyperlinks
look like:

=HYPERLINK("file:///C:\Documents and
Settings\User\Desktop\Book2.xls#Sheet2!B9")

Then a macro like:

Sub path_killer()
For Each r In Selection
v = r.Formula
s = Split(v, "\")
u = UBound(s)
r.Formula = Left(s(0), (Len(s(0)) - 2)) & s(u)
Next
End Sub


will change to the hyperlink to:

=HYPERLINK("file:///Book2.xls#Sheet2!B9")

As you see, the path has been removed.
--
Gary''s Student - gsnu200776


"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How do I create a macro to remove path from hyperlink "address

Show me a typical hyperlink you started with.
--
Gary''s Student - gsnu200776


"Ale" wrote:

Thanks Gary"s Student.

When I ran the macro I copied from your post, it added to the "Text to
display" inst ead of removing the path from the "Address"
--
May your footsteps be lost in the music of the forest.


"Gary''s Student" wrote:

Hi Ale:

It will depend on the form of the hyperlink. For example, if the hyperlinks
look like:

=HYPERLINK("file:///C:\Documents and
Settings\User\Desktop\Book2.xls#Sheet2!B9")

Then a macro like:

Sub path_killer()
For Each r In Selection
v = r.Formula
s = Split(v, "\")
u = UBound(s)
r.Formula = Left(s(0), (Len(s(0)) - 2)) & s(u)
Next
End Sub


will change to the hyperlink to:

=HYPERLINK("file:///Book2.xls#Sheet2!B9")

As you see, the path has been removed.
--
Gary''s Student - gsnu200776


"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.

  #5   Report Post  
Posted to microsoft.public.excel.misc
ale ale is offline
external usenet poster
 
Posts: 14
Default How do I create a macro to remove path from hyperlink "address

2007 10 22 V&M 0.jpg
Above is "Text to Display"

Below is hyperlink "Address"
N:\2007 Tax Deductibles\2007 10 22 V&M 0.jpg

The result I want is for the path to be removed so that
the hyperlink "Address" is
2007%2010%2022%20V&M%200.jpg
-- the hyperlink address without file path.

Thanks



--
May your footsteps be lost in the music of the forest.


"Gary''s Student" wrote:

Show me a typical hyperlink you started with.
--
Gary''s Student - gsnu200776


"Ale" wrote:

Thanks Gary"s Student.

When I ran the macro I copied from your post, it added to the "Text to
display" inst ead of removing the path from the "Address"
--
May your footsteps be lost in the music of the forest.


"Gary''s Student" wrote:

Hi Ale:

It will depend on the form of the hyperlink. For example, if the hyperlinks
look like:

=HYPERLINK("file:///C:\Documents and
Settings\User\Desktop\Book2.xls#Sheet2!B9")

Then a macro like:

Sub path_killer()
For Each r In Selection
v = r.Formula
s = Split(v, "\")
u = UBound(s)
r.Formula = Left(s(0), (Len(s(0)) - 2)) & s(u)
Next
End Sub


will change to the hyperlink to:

=HYPERLINK("file:///Book2.xls#Sheet2!B9")

As you see, the path has been removed.
--
Gary''s Student - gsnu200776


"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default How do I create a macro to remove path from hyperlink "address"?

Try this in a VBA module:

Sub RemoveAddr()
Dim x As Integer, r As Range
On Error Resume Next
For Each r In Selection
x = InStrRev(r.Hyperlinks(1).Address, "\")
If x 0 Then
r.Hyperlinks(1).Address = Right(r.Hyperlinks(1).Address, _
Len(r.Hyperlinks(1).Address) - x)
End If
Next r
End Sub

Hope this helps,

Hutch

"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.

  #7   Report Post  
Posted to microsoft.public.excel.misc
ale ale is offline
external usenet poster
 
Posts: 14
Default How do I create a macro to remove path from hyperlink "address

Hutch,

Thanks a ton.

I linked you code to a command button "Path_Killer" and it works like a
charm. Sweet!


--
May your footsteps be lost in the music of the forest.


"Tom Hutchins" wrote:

Try this in a VBA module:

Sub RemoveAddr()
Dim x As Integer, r As Range
On Error Resume Next
For Each r In Selection
x = InStrRev(r.Hyperlinks(1).Address, "\")
If x 0 Then
r.Hyperlinks(1).Address = Right(r.Hyperlinks(1).Address, _
Len(r.Hyperlinks(1).Address) - x)
End If
Next r
End Sub

Hope this helps,

Hutch

"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.

  #8   Report Post  
Posted to microsoft.public.excel.misc
ale ale is offline
external usenet poster
 
Posts: 14
Default How do I create a macro to remove path from hyperlink "address

Hutch,

Just tried it on multiple highlighted hyperlinks; the macro changed all at
once. Wow!
--
May your footsteps be lost in the music of the forest.


"Tom Hutchins" wrote:

Try this in a VBA module:

Sub RemoveAddr()
Dim x As Integer, r As Range
On Error Resume Next
For Each r In Selection
x = InStrRev(r.Hyperlinks(1).Address, "\")
If x 0 Then
r.Hyperlinks(1).Address = Right(r.Hyperlinks(1).Address, _
Len(r.Hyperlinks(1).Address) - x)
End If
Next r
End Sub

Hope this helps,

Hutch

"Ale" wrote:

Excel 2003
--
May your footsteps be lost in the music of the forest.

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
How do you remove a "Template Help" hyperlink from appearing? Little Ricky Excel Discussion (Misc queries) 2 August 6th 07 06:52 PM
Please do not remove "Address" command from Excel 2007 S Hung Excel Worksheet Functions 0 September 25th 06 11:34 AM
Remove content of last visited pages in "Insert Hyperlink" dialog Excel bloke Excel Worksheet Functions 4 June 12th 06 01:37 AM
create links to check boxes marked "good" fair"and "bad" pjb Excel Worksheet Functions 3 April 20th 06 03:17 AM
Macro to create "path" for save Chris Excel Discussion (Misc queries) 4 March 15th 06 11:38 AM


All times are GMT +1. The time now is 06:30 AM.

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

About Us

"It's about Microsoft Excel"