• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
开水房
ASP.NET
博客园    首页    新随笔    联系   管理    订阅  订阅
excel 将图片的链接URL 显示为图片 转

原帖: 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

End Sub 

posted on 2012-11-05 15:27  白开水皮皮  阅读(37263)  评论(1)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3