原帖: http://www.mrexcel.com/forum/excel-questions/604604-insert-image-url-images-into-cells-2.html
1. 如下VBA脚本将c1单元格内图片url链接在单元B1内把图片显示出来
Sub Test()
Dim Pic As Picture
Application.ScreenUpdating = False
With ActiveSheet.Range("C1")
Set Pic = .Parent.Pictures.Insert(.Value)
With .Offset(, -1)
Pic.Top = .Top
Pic.Left = .Left
Pic.Height = .Height
Pic.Width = .Width
End With
End With
Application.ScreenUpdating = True
End Sub
2. 整列的图片url显示为图片
Sub Test()
Dim Rng As Range
Dim Cell As Range
Dim Pic As Picture
Application.ScreenUpdating = False
Set Rng = Range("C1:C" & Range("c" & Rows.Count).End(xlUp).Row)
For Each Cell In Rng
With Cell
Set Pic = .Parent.Pictures.Insert(.Value)
With .Offset(, -1)
Pic.Top = .Top
Pic.Left = .Left
Pic.Height = .Height
Pic.Width = .Width
End With
End With
Next Cell
Application.ScreenUpdating = True
Dim Rng As Range
Dim Cell As Range
Dim Pic As Picture
Application.ScreenUpdating = False
Set Rng = Range("C1:C" & Range("c" & Rows.Count).End(xlUp).Row)
For Each Cell In Rng
With Cell
Set Pic = .Parent.Pictures.Insert(.Value)
With .Offset(, -1)
Pic.Top = .Top
Pic.Left = .Left
Pic.Height = .Height
Pic.Width = .Width
End With
End With
Next Cell
Application.ScreenUpdating = True
End Sub
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步