Convert hyperlink to image

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,074
Office Version
  1. 2019
Platform
  1. Windows
I have created a hyperlink to an image on my computer. However, instead of opening the default window picture app, is it possible to insert the image onto a sheet?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I wrote the file path in cells A1 & A2, for two different images on the computer.
I then made them hyperlinks back to the cells they were in (A1 & A2)

Then inserted the code below into the sheet code;


VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    If Target.Range.Address = ActiveCell.Address Then
        Call InsertImage
        End If
End Sub

Sub InsertImage()
Dim fName As String
fName = ActiveCell.Value
ActiveSheet.Pictures.Insert(fName).Select
End Sub
 
Upvote 0
When using this code, the default picture app still opens. Is there a way to stop the default picture app from opening?

VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Address = ActiveCell.Address Then
    Call InsertImage
End If
End Sub

Sub InsertImage()
Dim fName As String
fName = ActiveCell.Hyperlinks(1).Address
ActiveSheet.Pictures.Insert(fName).Select
End Sub
 
Upvote 0
Does your hyperlink link to the image? If so link it to its own cell on sheet with just the file path in the cell. I never had the problem
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,945
Members
449,275
Latest member
jacob_mcbride

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