|
Sub 插入图片()
Dim oWb As Object
Dim intFilesCount As Integer
Dim strFilePath As String
Application.ScreenUpdating = False '屏幕闪烁关闭
Dim oFd As Object
Dim rng As Range
Dim shp
For Each shp In ActiveSheet.Pictures
shp.Delete
Next shp
f = Dir(ThisWorkbook.Path & "\图片文件夹\*.gif")
hh = 2
lh = 1
Do While f <> ""
Cells(hh, lh).Select
Set rng = ActiveCell
cellL = ActiveCell.Left + 3
cellT = ActiveCell.Top
strFilePath = ThisWorkbook.Path & "\图片文件夹\" & f
Set shpPic = ActiveSheet.Shapes.AddPicture(strFilePath, msoFalse, msoTrue, cellL, cellT, 1, 1)
shpPic.Top = rng.Offset(m).Top + 1
shpPic.Left = rng.Offset(m).Left + 1
shpPic.Width = rng.Offset(m).Width - 1
shpPic.Height = rng.Offset(m).Height - 1
Set shpPic = Nothing
'hh = hh + 2
lh = lh + 1
If lh > 4 Then
lh = 1
hh = hh + 2
Else
lh = lh
hh = hh
End If
f = Dir
Loop
Application.ScreenUpdating = True '屏幕闪烁打开
MsgBox "ok"
End Sub
|
|