Results 1 to 6 of 6

Hyperlink Renaming

Threaded View

  1. #1
    Registered User
    Join Date
    06-18-2010
    Location
    Dallas
    MS-Off Ver
    Excel 2007
    Posts
    59

    Hyperlink Renaming

    Hello,

    I was wondering if I could get some help with hyperlink validation renaming.

    I currently have this working code:

    Option Explicit
    
    Sub AddHyperlinks()
    Dim fName As String
    Dim fRNG  As Range:     Set fRNG = Range("B2:B" & Rows.Count).SpecialCells(xlConstants)
    Dim f     As Range
    Dim fPath As String:    fPath = Range("D2")
    Dim fType As String:    fType = Range("C2")
    
        For Each f In fRNG
            fName = Dir(fPath & f & fType)
            If fName <> "" Then
                Range("A" & f.Row).FormulaR1C1 = "=HYPERLINK(""" & fPath & f & fType & """, ""Link"")"
            Else
                Range("A" & f.Row) = "No Link"
            End If
        Next f
    
    End Sub
    What this code does is compare a list of hyperlinks which are named a number of digits to a file name using cells C2 and D2 in combination with the file names listed under col B.
    If the hyperlink is valid, this program will keep the hyperlink active but rename the hyperlink name to "link"
    If the hyperlink does not exist(does not point to a particular picture in the directory), it will disable the hyperlink and change the hyperlink name to "no link"

    I was wondering if there was any way to keep the file name of the hyperlink and if the link does not exist, disable it change the hyperlink font color to black and make it not underlined.
    This way the hyperlinks with photos are distinguished from the files without a photo.

    I currently have the following code to hyperlink the file

    =HYPERLINK($D$2 & B2 & $C$2, "B2")
    As you can see, I have been naming the hyperlink the contents in B2
    After this hyperlink validation code executes, I would like the contents of the hyperlink to still be named the contents in Col B


    Thanks
    Last edited by vargs; 07-02-2010 at 08:26 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1