|
本帖最后由 zhanghai0602 于 2019-8-21 11:03 编辑
- Sub crPicturs()
- If ActiveSheet.Name = "1寸" Then crJpg 6
- If ActiveSheet.Name = "2寸" Then crJpg 4
- End Sub
- Sub crJpg(SizeX%)
- Application.ScreenUpdating = False
- Dim MyFile$, PathX$
- Dim arr$(300)
- Dim I%, J%, K%, L%
- Dim Hx!, Wx!
- Dim Shp As Shape
- For Each Shp In ActiveSheet.Shapes
- Shp.Delete
- Next
- Cells.ClearContents
- PathX = ThisWorkbook.Path & ""
- MyFile = Dir(PathX & "*.jpg")
- J = 0
- Do While MyFile <> ""
- J = J + 1
- arr(J) = MyFile
- MyFile = Dir
- Loop
- For I = 1 To J
- K = (I \ SizeX) * 2
- L = I Mod SizeX
- If L = 0 Then
- L = SizeX
- K = K - 2
- End If
- With Cells(K + 1, L)
- .Select
- Hx = .RowHeight
- Wx = .Width
- End With
- ActiveSheet.Pictures.Insert(PathX & arr(I)).Select
- Selection.Placement = xlFreeFloating
- With Selection.ShapeRange
- .LockAspectRatio = msoFalse
- .Height = Hx
- .Width = Wx
- End With
- Cells(K + 2, L) = arr(I)
- Next
- Application.ScreenUpdating = True
- Cells(1, 1).Select
- End Sub
复制代码
代码已测试无误,你试下 |
|