|
zjdh 发表于 2014-8-5 18:56
Private Sub CommandButton1_Click()
On Error Resume Next
Dim rngTemp As Range, k As Range, ...
老师,请问这个代码如果要更改,需要把原来的A列单元格插入图片,改为可以给A列的3、4或者多行合并单元格内插入图片该怎么改。其余功能不变。
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
Private Sub CommandButton2_Click()
ActiveSheet.Range("A:ZZ").ClearComments '删除选区内的批注
For Each shp In ActiveSheet.Shapes
If Not shp.Type = msoOLEControlObject Then shp.Delete
Next
End Sub |
|