|
楼主 |
发表于 2014-8-3 23:05
|
显示全部楼层
zjdh 发表于 2014-8-3 20:19
多此一举的办法
Private Sub CommandButton1_Click()
On Error Resume Next
非常感谢zjdh老师的耐心指点!非常感谢!完美解决!
老师,我考虑到经常需要筛选资料看图片,防止筛选后图片重叠,给代码加了几句,您看可适合?
Private Sub CommandButton1_Click()
On Error Resume Next
Dim rngTemp As Range, k As Range, shpPic As Picture
filepath = ThisWorkbook.Path & "\"
Set rngTemp = Application.InputBox("图片插入区域:", "选择单元格", Type:=8)
For Each k In rngTemp
With k
Filename = Dir(filepath & .Value & "*.jpg")
If k <> "" And Filename <> "" Then
ActiveSheet.Shapes.AddPicture filepath & Filename, False, True, .Left, .Top, .Width, .Height
.ClearComments
.AddComment
.Comment.Shape.Fill.UserPicture filepath & "\" & .Value & ".jpg"
.Comment.Shape.Height = 240
.Comment.Shape.Width = 320
Filename = ""
End If
End With
Next
filepath = ThisWorkbook.Path '(改变插入图片的属性)
ActiveSheet.Shapes.SelectAll
Selection.Placement = xlMoveAndSize
Range("A1").Select
End Sub
秉承老师的精神,感觉好东西就是要分享的,我把做好的资料附上,供大家参考!
|
|