EXCEL从图片链接获取图片

step1:

选中图片地址列

step2:开发工具→Visual Basic

文件→导入

导入我制作的脚本(代码见文章末尾)

点击excel的小图标回到表格界面。

点击【宏】

选中刚才导入的脚本,点执行,等待完成。

代码本体:

vbscript 复制代码
Sub InsertPicturesFromURLs()
    Dim rng As Range
    Dim cell As Range
    Dim picURL As String
    Dim picShape As Shape
    
    ' 设置工作范围为选定单元格
    Set rng = Selection
    
    ' 循环处理每个单元格
    For Each cell In rng
        ' 获取当前单元格的图片URL
        picURL = 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 If
    Next cell
End Sub
相关推荐
hello_simon10 小时前
免费在线文档工具,在线PDF添加空白页,免费在任意位置插入空白页,多样化的文件处理
pdf·html·excel·pdf转html·excel转pdf格式
chenchihwen12 小时前
常用 Excel VBA 技巧,简单好学易上手
excel
夔88812 小时前
Excel通过VBA脚本去除重复数据行并保存
java·服务器·excel
啊波次得饿佛哥14 小时前
excel中的VBA指令示例(一)
excel·vba
inxunoffice14 小时前
批量将 JSON 转换为 Excel/思维导入等其它格式
json·excel
忘忧记14 小时前
如何在 Excel 中处理并拆分你提供的这种混合单位的库存数据。
excel
CAT_cwds1 天前
EasyExcel-一款好用的excel生成工具
excel·easy
Eiceblue1 天前
C# 设置Excel中文本的对齐方式、换行、和旋转
开发语言·c#·excel