|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test3()
- Dim r%, i%
- Dim arr, brr
- Dim wordapp As Word.Application
- Dim worddoc As Word.Document
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(4, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a3").Resize(r - 2, c)
- End With
- Set wordapp = New Word.Application
- wordapp.Visible = True
- Set worddoc = wordapp.Documents.Add
- worddoc.Select
- With wordapp.Selection
- For i = 3 To 10
- With .Font
- .Name = "黑体"
- .Size = 20
- End With
- .ParagraphFormat.Alignment = wdAlignParagraphCenter
- .ParagraphFormat.CharacterUnitFirstLineIndent = 0
- .ParagraphFormat.FirstLineIndent = CentimetersToPoints(0)
- .TypeText Text:="成 绩 单"
- .TypeParagraph
- With .Font
- .Name = "宋体"
- .Size = 16
- End With
- .ParagraphFormat.Alignment = wdAlignParagraphLeft
- .Font.Bold = True
- .TypeText Text:="家长您好:"
- .Font.Bold = False
- .TypeParagraph
- .ParagraphFormat.CharacterUnitFirstLineIndent = 2
- ss = "你的孩子" & arr(i, 1) & ",学籍号:" & arr(i, 3) & ",本学期表现良好,现将本次考试成绩做以通报:"
- For j = 4 To UBound(arr, 2) Step 3
- ss = ss & arr(1, j) & arr(i, j) & ","
- Next
- .TypeText Text:=Left(ss, Len(ss) - 1) & "。"
- .TypeParagraph
- .InsertBreak Type:=1
- Next
- End With
- worddoc.SaveAs ThisWorkbook.Path & "\成绩单.doc"
- ' wordapp.Quit
- ' Set wordapp = Nothing
- ' Set worddoc = Nothing
- Application.DisplayAlerts = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|