Results 1 to 9 of 9

checking file exists before adding hyperlink

Threaded View

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    checking file exists before adding hyperlink

    I have the following code:
    Sub attachyperlinks()
    
    Dim MyCell As Object
    Dim Link As String
    
    
    For Each MyCell In Selection
        If MyCell <> "" Then
            ActiveSheet.Hyperlinks.Add Anchor:=MyCell, Address:="C:\Users\folderA\folderB\log\" & MyCell.Value & ".pdf", ScreenTip:="Click to Open"
        End If
    
    Next MyCell
    
    MsgBox ("Hyperlinks attached successfully.")
    
    End Sub

    Which attaches a hyperlink to the selected cells using cell contents are filename.

    What i now need to add is code to make it check if the file exists first before adding the hyperlink. If the file is not there then the hyperlink should not be added ie leave cell contents as is.

    Can someone please advise me?
    Last edited by arlu1201; 02-22-2013 at 04:04 AM.

Thread Information

Users Browsing this Thread

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

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