ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hyperlink VBA (https://www.excelbanter.com/excel-discussion-misc-queries/128878-hyperlink-vba.html)

[email protected]

Hyperlink VBA
 
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


Dave Peterson

Hyperlink VBA
 
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


wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com