Load Image base on the path in cell

dreamerkan

New Member
Joined
Jul 29, 2011
Messages
2
I would like to know if I can load the image from the Image path in the cell?

Can I control the size of image when the image is load?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You can adapt this to suit your page set-up; based on a directory structure of:-
Test/Images
Save your excel file in the parent (Test) directory
Create your images called pic1.png, pic2.png, pic3.png etc and save your images in the Image directory.
In cell A1 you can type “pic1” to display the image on screen.

Right click on the page tab and choose “View Code”, paste this into the right hand side of the page.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$A$1" Then Exit Sub
    Dim Pic As Picture
    On Error Resume Next
    Me.Pictures("PicTemp").Delete
    On Error GoTo 0
    Target.Offset(, 10).Select 'just sets where the cursor sits
    Set Pic = Me.Pictures.Insert(Me.Parent.Path & "\Images\" & Target.Value & ".png")
    Pic.Name = "PicTemp"
    
    'scale picture
Me.Pictures("PicTemp").Width = 200
'Me.Pictures("PicTemp").Height = 250
Me.Pictures("PicTemp").Top = 150
Me.Pictures("PicTemp").Left = 200

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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