|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
分享可选路径代码:
Private Sub CommandButton1_Click()
On Error Resume Next
Dim rngTemp As Range, k As Range, shpPic As Picture
Set rngTemp = Application.InputBox("图片插入区域:", "选择单元格", Type:=8)
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
If fd.Show = -1 Then
FilePath = fd.SelectedItems(1) & "\"
Else
Exit Sub
End If
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 = 180
.Comment.Shape.Width = 240
Filename = ""
End If
End With
Next
ActiveSheet.Shapes.SelectAll
Selection.Placement = xlMoveAndSize
Range("A1").Select
End Sub |
|