0

I have an excel file with several toggle buttons. When a toggle button is on and the "calculate" command button is pressed, my activeX image frame changes. However, I have all these files in the same directory so I'd have to send the file to my employees zipped. Is there anyway to like maybe load them into the excel workbook on a hidden sheet?

Thank you

Joseph Khub
  • 13
  • 1
  • 7

1 Answers1

0

I think the LoadPicture() function will look for a system file so you don't want that.

Add the pictures into images on a worksheet. This way they will be in the workbook.

enter image description here

Then right click the image you just added and select properties. Select picture property and navigate to your image file.

enter image description here

You can change the name to make sense of your pictures also. So they don't have to be Image1 Image2 etc.

Then in your code set the picture that you want to change = the image that you want.

If something
    Image1.Picture = Image2.Picture
Else
    Image1.Picture = Image3.Picture
End If

Here Image1 is the picture that changes based on what happens when the calculate button is pressed. Image3 is one of the images that you loaded into the workbook.

If you are going to store them on some other worksheet you may need to declare a worksheet object and set it to that sheet

Dim ws As Excel.Worksheet
Set ws = ActiveWorkbook.Sheets("ImageWorksheet")
Image1.Picture = ws.Image3.Picture

or something like this may work.

ActiveWorkbook.Sheets("ImageWorksheet").Image3.Picture

Something like that.

MatthewD
  • 6,719
  • 5
  • 22
  • 41
  • Ok I get that part...now how do I "add the pictures into images on a worksheet" – Joseph Khub Aug 17 '15 at 13:50
  • might seem silly i know...but i thought loadPic is the only way – Joseph Khub Aug 17 '15 at 13:51
  • I think that is the only way to get a file from outside the workbook. And this is the only way I know of to store images in the workbook and use them. I'm sure there are other ways. – MatthewD Aug 17 '15 at 13:57