|
楼主 |
发表于 2020-5-23 17:28
|
显示全部楼层
- Sub 生成走读生校牌()
- Application.ScreenUpdating = False
- Dim x, k, m, f As Integer
- Dim fs1$, fs2$
- For Each a In Sheets("打印走读").Shapes
- a.Delete
- Next
- Sheets("打印走读").Rows("11:65535").Delete
- Sheets("打印走读").Range("B5:C5,B6:C6,B7:D7,B8:D8,B9:D9,G5:H5,G6:H6,G7:I7,G8:I8,G9:I9").ClearContents
- k = Sheets("走读").Cells(Rows.Count, 1).End(xlUp).Row
- If Int((k - 1) / 2) = (k - 1) / 2 Then
- f = k / 2 - 1
- Else
- f = Int((k - 1) / 2)
- End If
- For m = 1 To f
- Sheets("打印走读").Rows("1:10").Copy Sheets("打印走读").Cells(Rows.Count, 1).End(xlUp).Offset(2)
- Next m
- For x = 2 To k Step 2
- Sheets("打印走读").Cells(x * 4.5 - 4, 2) = Sheets("走读").Cells(x, 2).Value
- Sheets("打印走读").Cells(x * 4.5 - 3, 2) = Sheets("走读").Cells(x, 3).Value
- Sheets("打印走读").Cells(x * 4.5 - 2, 2) = Sheets("走读").Cells(x, 4).Value
- Sheets("打印走读").Cells(x * 4.5 - 1, 2) = Sheets("走读").Cells(x, 5).Value
- Sheets("打印走读").Cells(x * 4.5, 2) = Sheets("走读").Cells(x, 6).Value
- Sheets("打印走读").Cells(x * 4.5 - 4, 7) = Sheets("走读").Cells(x + 1, 2).Value
- Sheets("打印走读").Cells(x * 4.5 - 3, 7) = Sheets("走读").Cells(x + 1, 3).Value
- Sheets("打印走读").Cells(x * 4.5 - 2, 7) = Sheets("走读").Cells(x + 1, 4).Value
- Sheets("打印走读").Cells(x * 4.5 - 1, 7) = Sheets("走读").Cells(x + 1, 5).Value
- Sheets("打印走读").Cells(x * 4.5, 7) = Sheets("走读").Cells(x + 1, 6).Value
- fs1 = ThisWorkbook.Path & "\学生照片" & CStr(Sheets("走读").Cells(x, 2)) & ".jpg"
- If Dir(fs1) <> "" Then
- Sheets("打印走读").Select
- Sheets("打印走读").Range("b" & x * 4.5 - 5 & ":c" & x * 4.5 - 5).Select
- ActiveSheet.Pictures.Insert(fs1).Select
- With Selection
- .Top = Sheets("打印走读").Range("b" & x * 4.5 - 5 & ":c" & x * 4.5 - 5).Top + 1
- .Left = Sheets("打印走读").Range("b" & x * 4.5 - 5 & ":c" & x * 4.5 - 5).Left + 1
- .Width = Sheets("打印走读").Range("b" & x * 4.5 - 5 & ":c" & x * 4.5 - 5).Width - 1
- .Height = Sheets("打印走读").Range("b" & x * 4.5 - 5 & ":c" & x * 4.5 - 5).Height - 1
- End With
- End If
- fs2 = ThisWorkbook.Path & "\学生照片" & CStr(Sheets("走读").Cells(x + 1, 2)) & ".jpg"
- If Dir(fs2) <> "" Then
- Sheets("打印走读").Range("g" & x * 4.5 - 5 & ":h" & x * 4.5 - 5).Select
- ActiveSheet.Pictures.Insert(fs2).Select
- With Selection
- .Top = Sheets("打印走读").Range("g" & x * 4.5 - 5 & ":h" & x * 4.5 - 5).Top + 1
- .Left = Sheets("打印走读").Range("g" & x * 4.5 - 5 & ":h" & x * 4.5 - 5).Left + 1
- .Width = Sheets("打印走读").Range("g" & x * 4.5 - 5 & ":h" & x * 4.5 - 5).Width - 1
- .Height = Sheets("打印走读").Range("g" & x * 4.5 - 5 & ":h" & x * 4.5 - 5).Height - 1
- End With
- End If
- Next x
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|