Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / March 2008

Tip: Looking for answers? Try searching our database.

How do I create a macro to remove path from hyperlink "address"?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ale - 31 Mar 2008 15:19 GMT
Excel 2003
Signature

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

Gary''s Student - 31 Mar 2008 17:16 GMT
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.
Signature

Gary''s Student - gsnu200776

> Excel 2003
Ale - 31 Mar 2008 17:43 GMT
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"
Signature

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

> Hi Ale:
>
[quoted text clipped - 22 lines]
>
> > Excel 2003
Gary''s Student - 31 Mar 2008 17:46 GMT
Show me a typical hyperlink you started with.
Signature

Gary''s Student - gsnu200776

> Thanks Gary"s Student.  
>
[quoted text clipped - 27 lines]
> >
> > > Excel 2003
Ale - 31 Mar 2008 18:02 GMT
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

Signature

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

> Show me a typical hyperlink you started with.
>
[quoted text clipped - 29 lines]
> > >
> > > > Excel 2003
Tom Hutchins - 31 Mar 2008 18:29 GMT
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

> Excel 2003
Ale - 31 Mar 2008 18:46 GMT
Hutch,

Thanks a ton.

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

Signature

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

> Try this in a VBA module:
>
[quoted text clipped - 15 lines]
>
> > Excel 2003
Ale - 31 Mar 2008 18:48 GMT
Hutch,

Just tried it on multiple highlighted hyperlinks; the macro changed all at
once.  Wow!
Signature

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

> Try this in a VBA module:
>
[quoted text clipped - 15 lines]
>
> > Excel 2003

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.