Hyperlink VBA

K

kate

Hi All,

I have VBA to insert and resize a picture. It also adds the file name
to the cell next to it. I would like to have that picture or filename
be automatically hyperlinked to its source. Is that possible?

Thanks in advance!
-Kate
 
D

Dave Peterson

Maybe you can modify this:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim myPict As Picture

With Worksheets("Sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
With myCell
Set myPict = .Parent.Pictures.Insert(.Value)
.Parent.Hyperlinks.Add anchor:=myPict.ShapeRange.Item(1), _
Address:=.Value
End With
Next myCell
End Sub
 
Top