|
楼主 |
发表于 2009-7-3 17:26
|
显示全部楼层
换了个工作表,楼上的代码又不行了,见附件
弄了一个下午,也试了YUANZHUPING老师的VBA代码解析,也没成功
我在想,除了图片路径,其他的应该不需要更改什么吧?实在不明白
代码如下:
Sub inserpic()
Application.ScreenUpdating = False
Dim iRow As Single, Shp As Shape, Target As Range, FilPath As String, sh As Object
ActiveSheet.Shapes.SelectAll
On Error GoTo 1
For Each sh In Selection
If Left(sh.Name, 3) = "Pic" Then sh.Delete
Next
1:
With ActiveSheet
For iRow = 2 To .Cells(65536, 1).End(xlUp).Row
FilPath = ThisWorkbook.Path & "\图片\" & .Cells(iRow, 4) & ".bmp"
If Dir(FilPath) <> "" Then
.Pictures.Insert(FilPath).Select
Set Target = .Cells(iRow, 5)
With Selection
.Top = Target.Top + 1
.Left = Target.Left + 1
.Width = Target.Width - 1
.Height = Target.Height - 1
End With
End If
Next
End With
Application.ScreenUpdating = True
End Sub |
|