step1:
选中图片地址列
step2:开发工具→Visual Basic
文件→导入
导入我制作的脚本(代码见文章末尾)
点击excel的小图标回到表格界面。
点击【宏】
选中刚才导入的脚本,点执行,等待完成。
代码本体:
Sub InsertPicturesFromURLs()Dim rng As RangeDim cell As RangeDim picURL As StringDim picShape As Shape' 设置工作范围为选定单元格Set rng = Selection' 循环处理每个单元格For Each cell In rng' 获取当前单元格的图片URLpicURL = cell.Value' 检查URL是否为空If picURL <> "" Then' 插入图片Set picShape = ActiveSheet.Shapes.AddPicture(picURL, _LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _Left:=cell.Left, Top:=cell.Top, Width:=cell.Width, Height:=cell.Height)End IfNext cell
End Sub