|
Sub 插入图片()
Application.ScreenUpdating = False '屏幕闪烁关闭
Dim shp
With Sheets("sheet1")
For Each shp In .Pictures
If shp.TopLeftCell.Column < 7 Then
shp.Delete
End If
Next shp
ar = .UsedRange
For i = 1 To UBound(ar)
For j = 1 To UBound(ar, 2)
If Trim(ar(i, j)) <> "" Then
If IsNumeric(ar(i, j)) Then
tp = Dir(ThisWorkbook.Path & "\图片\" & ar(i, j) & ".png")
If tp <> "" Then
.Cells(i, j).Select
cellL = ActiveCell.Left + 3
cellT = ActiveCell.Top
Set shpPic = ActiveSheet.Shapes.AddPicture(ThisWorkbook.Path & "\图片\" & tp, msoFalse, msoTrue, cellL, cellT, 1, 1)
shpPic.Top = .Cells(i, j).Top + 1
shpPic.Left = .Cells(i, j).Left + 1
shpPic.Width = .Cells(i, j).Width - 1
shpPic.Height = .Cells(i, j).Height - 1
Set shpPic = Nothing
End If
End If
End If
Next j
Next i
End With
Application.ScreenUpdating = True '屏幕闪烁打开
MsgBox "ok"
End Sub
|
|