|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 zjdh 于 2014-8-3 15:41 编辑
那就这样吧
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")
Set shpPic = ActiveSheet.Shapes.AddPicture(filepath & Filename, False, True, .Left + 1, .Top + 1, .Width, .Height)
If Dir(filepath & .Value & ".jpg") <> "" Then
.ClearComments
.AddComment
.Comment.Shape.Fill.UserPicture filepath & "\" & Trim(k) & ".jpg"
.Comment.Shape.Height = 240
.Comment.Shape.Width = 320
End If
End With
Next
End Sub |
|