|
发表于 2012-9-25 22:42
|
显示全部楼层
本楼为最佳答案
本帖最后由 suye1010 于 2012-9-25 22:46 编辑
- Sub PRwithPic(All As Boolean)
- Dim i As Integer, PageNo As Integer, j As Integer, k As Integer, ItemNo, Pic
- On Error Resume Next
- ActiveSheet.PageSetup.PrintArea = "$A$1:$G$28"
- If All Then
- PageNo = 1000
- Else
- PageNo = Cells(2, 11)
- End If
- If PageNo * 8 + 1 < Sheet1.Cells(65536, 1).End(xlUp).Row Then
- ItemNo = PageNo * 8 + 1
- Else
- ItemNo = Sheet1.Cells(65536, 1).End(xlUp).Row
- End If
- For i = 2 To ItemNo Step 8
- ActiveSheet.Pictures.Delete
- For j = 1 To 8
- For k = 1 To 5
- Cells(Int((j - 1) / 2) * 7 + k + 1, IIf(j Mod 2, 2, 6)) = Sheet1.Cells(i + j - 1, k + 1)
- Next k
- Set Pic = ActiveSheet.Pictures.Insert(ThisWorkbook.Path & "" & Sheet1.Cells(i + j - 1, 7))
- Pic.ShapeRange.Left = Cells(Int((j - 1) / 2) * 7 + 2, IIf(j Mod 2, 3, 7)).Left
- Pic.ShapeRange.Top = Cells(Int((j - 1) / 2) * 7 + 2, IIf(j Mod 2, 3, 7)).Top
- Pic.ShapeRange.Width = Cells(Int((j - 1) / 2) * 7 + 2, IIf(j Mod 2, 3, 7)).Width
- Pic.ShapeRange.Height = Cells(Int((j - 1) / 2) * 7 + 2, IIf(j Mod 2, 3, 7)).Height * 4
- Next j
- ActiveSheet.PrintOut
- Next i
- End Sub
- Sub PAll()
- Call PRwithPic(True)
- End Sub
- Sub Ppage()
- Call PRwithPic(False)
- End Sub
复制代码 |
|