|
楼主 |
发表于 2014-6-6 15:10
|
显示全部楼层
Sub 导入图片到批注()
Dim cell As Range, fd, t, FilPath$
Dim X As Long
Dim Y As Long
Dim mystr As String
On Error Resume Next
Sheets("TP").Activate
Y = Range("a10000").End(xlUp).Row
For X = 2 To Y
Range("A" & X).ClearComments
Next X
Set fd = Application.FileDialog(msoFileDialogFolderPicker) '选择一个文件夹
If fd.Show = -1 Then
t = fd.SelectedItems(1)
Else
Exit Sub
End If
mystr = InputBox("输入批注外形序号" & Chr(10) & "1 矩形, 2 书卷, 3 横卷, 4 竖卷" & Chr(10) & "5 椭圆, 6 菱形, 7 柱形, 8 圆矩", "选择批注外形", 8)
If mystr = "" Then
Exit Sub
End If
For Each cell In Range("A2:A" & Y)
FilPath = t & "\" & cell.Text & ".jpg"
If Dir(FilPath) <> "" Then
With cell.AddComment
.Visible = True
.Text Text:=""
.Shape.Select True
Selection.ShapeRange.AutoShapeType = Choose(mystr, msoShapeRectangle, msoShapeFoldedCorner, msoShapeHorizontalScroll, _
msoShapeVerticalScroll, msoShapeOval, msoShapeDiamond, msoShapeCan, msoShapeRoundedRectangle)
Selection.ShapeRange.Fill.UserPicture t & "\" & cell.Text & ".jpg"
.Shape.Width = 90
.Shape.Height = 90
.Visible = False
End With
End If
Next
End Sub |
|