Hi all...this is in a way linked to this http://vbaexpress.com/forum/showthread.php?t=12553
Here's what i have for collecting a list of pictures in a folder Ideally if i could collect a list of photos (the names would all be the ID numbers used for the staff i.e AE 1 NW) everytime my Staff workbook is opened and create hyperlinks to the pictures on my staff sheet the staff ID's are held in column A and the hyperlink should go in column L for each found ID, this way the hyperlink will always be to the most recent photo of the employee!
[VBA]
Option Explicit
Sub Last_Created_Hyperlink_Test()
Dim fso As New FileSystemObject
Dim fls As Files
Dim i As Integer
Dim Picfile, MyFile As Variant
Set fls = fso.GetFolder("C:\Documents and Settings\Simon\Desktop\new pics").Files
i = 2
With Worksheets("Sheet1")
.Cells(1, 1) = "File Name"
.Cells(1, 2) = "File Size"
.Cells(1, 3) = "Date Created"
.Cells(1, 4) = "Link To Photo"
For Each Picfile In fls
MyFile = "C:\Documents and Settings\Simon\Desktop\Staff ID Photos\" & Picfile
.Cells(i, 1) = Picfile.Name
.Cells(i, 2) = Picfile.Size
.Cells(i, 3) = Picfile.DateCreated
.Cells(i, 4).Hyperlinks.Add Anchor:=Selection, Address:=MyFile, TextToDisplay:="Yes"
i = i + 1
Next
End With
Columns("A").AutoFit
End Sub
[/VBA]I have tried creating hyperlinks in my testbook as per the code above but it doesnt work.
Any help or ideas appreciated!
Regards,
SImon