How to insert a picture's address as hyperlink to a cell?
Sub Tester()
Dim v, s
v = Application.GetOpenFilename()
If v = False Then Exit Sub
If Dir(v) = "" Then Exit Sub
Set s = ActiveSheet.Pictures.Insert(v)
With s
.Width = 200
.Height = 200
.Name = "blah"
.Top = ActiveSheet.Range("B10").Top
.Left = ActiveSheet.Range("B10").Left
End With
With ActiveSheet
.Hyperlinks.Add .Range("B9"), v
End With
End Sub
Tim
"Sam Kuo" wrote in message
...
I use the script below to allow user to click on a command button to open
the
"Insert Picture" pop-up window and pick a picture to be inserted into a
particular merged cell.
I wonder if it's possible to also dynamically insert the picture's address
as a hyperlink to a different cell after the picture is inserted, and how?
Thanks in advance :-)
**************
' This is a simplified version of my script, without the irrelevant lines
to
this question
Sub CommandButton_Click()
Const MY_PIC As String = "MyPic"
Dim ImageCell As Range
Set ImageCell = Sheet3.Range("B10").MergeArea
ImageCell.Select
Application.Dialogs(xlDialogInsertPicture).Show
If TypeName(Selection) < "Picture" Then Exit Sub
On Error Resume Next
ActiveSheet.Shapes(MY_PIC).Delete
On Error GoTo 0
With Selection
.Name = MY_PIC
End With
End Sub
|