简体   繁体   English

在Excel VBA中选择图像

[英]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. 我在一个额外的文件夹中大约有20张图像,应该选择其中一张并将其显示在我的用户表单中。 They are named from Image1 to image20. 它们的名称从Image1到image20。 The selected picture is based on a seed function which gives out a value between 1 and 20. 所选图片基于种子函数,该函数给出1到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. 示例:seed函数给出值13。使用该信息,应提取image13并将其放置在用户窗体中。

It seems to me like not a big deal but i'm a newbie in vba and cannot find the answer. 在我看来,这没什么大不了的,但是我是vba的新手,找不到答案。 Thank you. 谢谢。 :) :)

You can use the LoadPicture() Method. 您可以使用LoadPicture()方法。

Eg 例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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