Consulting

Results 1 to 4 of 4

Thread: Solved: Auto Hyperlink to Folders

  1. #1

    Solved: Auto Hyperlink to Folders

    Hey,

    I am using this code:

    [vba]
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim FullPathName As String
    If Target.Cells.Count > 1 Then Exit Sub
    If Target = "" Then Exit Sub

    If Target.Column = 2 Then
    Application.EnableEvents = False
    FullPathName = "H:\Lab\" & Target
    Target.Clear

    Target.Hyperlinks.Add Anchor:=Target, _
    Address:=FullPathName, TextToDisplay:=FullPathName
    Application.EnableEvents = True
    End If


    End Sub
    [/vba]

    Everything works the way I want it, but one thing. Instead of displaying the "Full Path Name," I want it to display the folder name only. Looked everywhere and could not figure out what to do. Any insight into this would be welcomed.

    Thank you.

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    [VBA]Address:=FullPathName, TextToDisplay:=Mid(FullPathName, InstrRev(FullPathName,"\")+1)
    [/VBA]

    We are what we repeatedly do. Excellence, therefore, is not an act but a habit.
    Aristotle

  3. #3
    Thanks geekgirlau, that is exactly what I needed. Here is a picture of a rabbit to show my appreciation.


    .( Y )
    .( . .)
    c( ")(")

  4. #4
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    You're welcome - don't forget to mark the thread as solved (Thread Tools at the top of the page)

    We are what we repeatedly do. Excellence, therefore, is not an act but a habit.
    Aristotle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •