+ Reply to Thread
Results 1 to 3 of 3

Hyperlink to document using partial document name

  1. #1
    Registered User
    Join Date
    04-13-2010
    Location
    Huntsville, Alabama
    MS-Off Ver
    Excel 2003
    Posts
    5

    Hyperlink to document using partial document name

    Hi,

    I have an excel worksheet.
    In column A there is a list of numbers
    A1 = "150"
    A2 = "151"

    In a folder on my C: drive there are photos. Each cell in column A should hyperlink to the corresponding photo on the C: drive. The problem is that the filename for the photo will not be an exact match to the cell.
    cell A1 = "150"
    photo filename = "150_Customer"

    The values in the cell are always the first 3 values in the filename.
    Excel needs to open the file based on the first 3 vaules only and ignore the rest of the filename.
    Can anyone help me with this?

  2. #2
    Registered User
    Join Date
    04-13-2010
    Location
    Huntsville, Alabama
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Hyperlink to document using partial document name

    Here is an example of the code I am currently using. It turns whatever value I enter into the cell into a hyperlink to a photo on the designated directory.


    [code]
    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 = 1 Then
    Application.EnableEvents = False
    FullPathName = "\\gfchuntns02\groups\CustomerProfile\Ba_PRICING CYLINDER\QUOTES\" & Target & ".jpg"
    Clear.Target

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

    End Sub[code]
    Last edited by teylyn; 04-13-2010 at 08:08 PM. Reason: code tags

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Hyperlink to document using partial document name

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I've added the tags for you this time, but please remember to use them from now on.

+ Reply to Thread

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