求助,网上摘的excel VBA代码在2013版本中执行不了,要怎么修改? 10
目的是将excel中已有的url图片链接直接转化为图片,从网上摘了下面这段代码,但是执行的时候提示“错误1004,不能取得类Pictures的Insert属性”,貌似是因...
目的是将excel中已有的url图片链接直接转化为图片,从网上摘了下面这段代码,但是执行的时候提示“错误1004,不能取得类Pictures的Insert属性”,貌似是因为代码是2003的,2013里面用不了,求高手帮忙修改!
代码如下:
Sub Test2()
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 展开
代码如下:
Sub Test2()
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 展开
2个回答
展开全部
Sub Test2()
Dim Rng As Range
Dim Cell As Range
Dim Pic As Picture
Dim Pat as String‘这里修改成一下
Application.ScreenUpdating = False
Pat = "D:\我的桌面\我的照片.jpg"'这里修改成你的图片所存放的路径
Set Rng = Range("C1:C" & Range("c" & Rows.Count).End(xlUp).Row)
For Each Cell In Rng
With Cell
Set Pic = .Parent.Pictures.Insert(Pat)‘这里修改成一下
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
这样应该就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询