In my Office 2010 xlsm sheet I have created a fixed size Image ActiveX control called Image1. The following macros should in my opinion set the image path to the one which specified in cell B3, but it fails with “Run-time error ‘424’: Object required” error message at the line Image1.Picture. I checked that imPath is equal to "C:\some\valid\image\path.jpg".
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$3" Then
imPath = Range("B3")
Image1.Visible = True
Image1.Picture = imPath
Image1.PictureSizeMode = fmPictureSizeModeZoom
Image1.BorderStyle = fmBorderStyleNone
Image1.BackStyle = fmBackStyleTransparent
End If
End Sub
What is wrong here? BTW, is there any way to check if the specified file actually exists?
A quick look into excel-help, searching for picture, suggests that you use this line:
To check if the file exists, use a FileSystemObject
edit
by the way you can use
to set imPath (not tested, but quite sure of this)