Have .jpg files within excel when using ActiveX Image Control

流过昼夜 提交于 2019-12-13 06:41:05

问题


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


回答1:


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.

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

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.



来源:https://stackoverflow.com/questions/32050403/have-jpg-files-within-excel-when-using-activex-image-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!