Autolink

pnasz

New Member
Joined
Apr 16, 2012
Messages
19
i have image code 02-71234
which i want to autolink to the folder on the network.
Folder contain lot of file but i want to open the file related to the image code, for example for code 02-71234 i want to open the file 02-71234 (20.4 grams) which is present in a directory
 
Hi and Welcome to the Board,

Please clarify a few things?

1. Is the image you mention in the workbook, or do you want a Text Hyperlink from the Workbook to open an image file?

2. Would the Hyperlink have to "find" a file that matches a pattern (like 02-71234*.tif) or is there a single specific file that would be linked?

3. Is it possible that two images could match that pattern, and what should the result be if that happens?
 
Upvote 0
Its a excel workbook containing the image.
workbook is in the folder located on network.
when i type the image code on the particular column link should be generated automatically.
when i click the link workbook should be open containing pictures.
 
Upvote 0
I'm not understanding you.

What is the file type (file extension) of the file that should be opened when you click the link?

As asked previously,
2. Would the Hyperlink have to "find" a file that matches a pattern (like 02-71234*.tif) or is there a single specific file that would be linked?

3. Is it possible that two images could match that pattern, and what should the result be if that happens?
 
Upvote 0
link will look for anyfile related to the name i typed in the cell

the Hyperlink have to "find" a file that matches a pattern (like 02-71234*.*)
 
Upvote 0
The solution would need to use VBA to "find" a file matching that pattern then open it.

Still awaiting your reply to these two questions....:)
What is the file type (file extension) of the file that should be opened when you click the link?

3. Is it possible that two images could match that pattern, and what should the result be if that happens?
 
Upvote 0
Below is some code that you could try.

Paste this code into the Sheet Code Module of the Sheet where you will enter the Image Codes.
(Right-Click on the Sheet's Tab > View Code... to get to the Sheet Code Module.)

Edit the Path of the Folder to be searched and the Column you'll enter the Image Codes, if other than Column "A"

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Const sPath = "[COLOR="Blue"][B]C:\TEST\[/B][/COLOR]"
    Dim sFilename As String, sCode As String
    
    sCode = Target.Text
    
    If Intersect(Target, Columns("[B][COLOR="blue"]A[/COLOR][/B]")) Is Nothing Or _
        Target.Count > 1 Or _
        sCode = vbNullString Then Exit Sub
        
    On Error GoTo CleanUp
             
    sFilename = Dir(sPath & sCode & "*")
    If sFilename = vbNullString Then
        MsgBox "No matching files found for code " & sCode
    Else
      Application.EnableEvents = False
      Me.Hyperlinks.Add _
            Anchor:=Target, Address:=sPath & sFilename, _
            TextToDisplay:=sFilename
    End If
CleanUp:
    Application.EnableEvents = True
End Sub
 
Upvote 0
Thanx a lot for your reply.

here we are specifying for the file location that is C:\TEST\

is it possible to search for the file in all the sub directories inside test directory.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top