|
Sub charudayin()
Dim a%, b$, c$, abc$, i, s, m, hh, lh, f, shp
Dim rr
With Sheets("准考证打印")
rr = Array(4, 3, 4, 9, 21, 3, 21, 9)
a = .Cells(42, 2).Value
b = .Cells(42, 5).Value
For Each shp In .Shapes
If shp.TopLeftCell.Row < 30 And shp.TopLeftCell.Row > 2 Then
shp.Delete
End If
Next shp
For i = a To Val(b) Step 4
m = 0
For s = i To i + 3
If s <= Val(b) Then
m = m + 2
.[d17] = s
hh = rr(m - 2) - 1
lh = rr(m - 1) - 1
f = Dir(ThisWorkbook.Path & "\相片\" & CStr(.Cells(hh, lh)) & ".jpg")
If f <> "" Then
Cells(hh + 1, lh + 1).Resize(4, 2).Select
.Pictures.Insert(ThisWorkbook.Path & "\相片\" & f).Select
With Selection.ShapeRange
Selection.ShapeRange.LockAspectRatio = msoFalse
.Top = Cells(hh + 1, lh + 1).Resize(4, 2).Top + 1
.Left = Cells(hh + 1, lh + 1).Resize(4, 2).Left + 1
.Width = Cells(hh + 1, lh + 1).Resize(4, 2).Width
.Height = Cells(hh + 1, lh + 1).Resize(4, 2).Height
End With
End If
End If
Next s
.PrintOut
Next i
End With
MsgBox "打印结束", 64, "打印"
End Sub
|
|