简体   繁体   中英

Selecting Image in Excel VBA

I have around 20 images in an extra folder and one of them should be selected and presented on my userform. They are named from Image1 to image20. The selected picture is based on a seed function which gives out a value between 1 and 20.

My question is, how can I address and extract one certain image from the rest of the images of the folder just because of its name?

Example: the seed function gives out the value 13. With that information the image13 should be extracted and placed my userform.

It seems to me like not a big deal but i'm a newbie in vba and cannot find the answer. Thank you. :)

You can use the LoadPicture() Method.

Eg

 Image1.Picture = LoadPicture("C:\Temp\Test.jpeg")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM