Load a pic into ActiveX Image control

MartinK

Active Member
Joined
Oct 30, 2003
Messages
384
Hello,

I have inserted an Image ActiveX control on my sheet. I can load jpgs in it by choosing Properties - Picture.

I cannot find a way how to load the picture based on a value in a different cell, e.g. A1 = Test1, load Test1.jpg, etc. The Intellisense and AuroList members is betraying me, as usual.

BTW, does anbody have a good link about how the Autolisting help when writting the code helps? Sometimes I write a period (dot) and the members are listed. Sometimes not (like in this case).

Thank you
Martin
 
I did a control like in below, but I receive an error when I didn't select a file.

ActiveX Control Image Name: Logo
ActiveX Control Button Name: LogoEkle
ActiveX Control Button Name: LogoSil

LogoEkle : Open a dialog and after you select a picture it loads the picture on the image control named Logo.

LogoSil : Loads empty name to the image control named Logo. So picture will be deleted.

Problem: After I click LogoEkle button opens a dialog if I cancel the dialog it gives error message.

Codes:

Private Sub LogoEkle_Click()
Dim fname As String

fname = Application.GetOpenFilename(filefilter:= _
"Jpeg Files(*.Jpg),*.Jpg", Title:="Select Image To Open")
Logo.Picture = LoadPicture(fname)

End Sub

Private Sub LogoSil_Click()

Logo.Picture = LoadPicture()

End Sub

I have tried some changes, but it didn't work. Could you please help me?

First I tried;

Private Sub LogoEkle_Click()
Dim fname As String

fname = Application.GetOpenFilename(filefilter:= _
"Jpeg Files(*.Jpg),*.Jpg", Title:="Select Image To Open")

If fname = False Then
Exit Sub
Else
Logo.Picture = LoadPicture(fname)
End If
End Sub
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,214,798
Messages
6,121,630
Members
449,041
Latest member
Postman24

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