|
本帖最后由 叫我赵日天 于 2017-3-7 13:04 编辑
- Sub tt3()
- Dim num%, i%, stpNum%
- Dim Myph$, TpNm$, arr, Tp As Shape
- For Each Tp In ActiveSheet.Shapes
- If Tp.Type = 11 Then Tp.Delete
- Next
- Range("1:3").ClearContents
- num = Range("a4").Value
- Myph = ThisWorkbook.Path & "\photo"
- arr = Sheets("名单").Range(Sheets("名单").Cells(IIf([a4] = 6, 2, [a4] - 4), 2), Sheets("名单").Cells([a4] + 1, 2))
- Do While stpNum < num
- For i = 1 To 3
- stpNum = stpNum + 1
- TpNm = arr(stpNum, 1)
- If Dir(Myph & TpNm & ".jpg") <> "" Then
- With Cells(i, Int((stpNum - 1) / 3) + 1)
- .Value = TpNm
- Sheets("打印页").Shapes.AddPicture Filename:=Myph & TpNm & ".jpg", LinkToFile:=True, SaveWithDocument:=True, _
- Left:=.Left + 5, Top:=.Top + 5, Width:=.Width - 10, Height:=.Height - 10
-
- End With
- End If
- On Error GoTo err
- Next
- Loop
- err:
- Application.EnableEvents = True
- End Sub
复制代码
|
|