vba Excel 工作表中不同单元格中的多张图片

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13899451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:50:34  来源:igfitidea点击:

Multiple Pictures in Excel Sheet in DIfferent Cells

excelexcel-vbaexcel-2007vba

提问by VJV

Due to the nature of business, I have:

由于业务性质,我有:

  • Multiple Pictures in a Folder
  • 文件夹中的多张图片

I am looking for a small macro which can actually:

我正在寻找一个小宏,它实际上可以:

  • Take All pictures from Specified Folder
  • Insert them one by one in different cell with a fixed size in each new row
  • 从指定文件夹中拍摄所有照片
  • 将它们一个一个地插入到每个新行中固定大小的不同单元格中

Please suggest the best way

请建议最好的方法

回答by bonCodigo

You may take a look at this post for inserting pictures from a folder into your worksheet.

您可以查看这篇文章,将文件夹中的图片插入到您的工作表中

Since you only have one path name without specific image name, I suggest you to rename your pictures into a sequential name list.

由于您只有一个路径名而没有特定的图像名称,我建议您将图片重命名为一个顺序名称列表。

e.g. Folder has 10 images img01img02img03... img10

例如文件夹有 10 张图片 img01img02img03... img10

Then you may modify the above code to loop through based on the last two digits of the picture name. You may set max count of for loop based on the number of images you have in the folder.

然后你可以修改上面的代码,根据图片名称的后两位数字进行循环。您可以根据文件夹中的图像数量设置 for 循环的最大计数。

For i = 1 to 10
  '-- insert picture
Next i

Once you have tried that out, if you have futher questions you may comment. Happy to help if so.

一旦你试过了,如果你有其他问题,你可以发表评论。如果是这样,很乐意提供帮助。