TO 孔兄,请参: '* +++++++++++++++++++++++++++++
'* Created By I Love You_Word!@ExcelHome 2005-7-30 15:47:17
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------
Sub 三课试做()
Dim FirstRange As Range, CentRange As Range, LastRange As Range
With ActiveDocument
Set FirstRange = .Paragraphs.First.Range '设置第一段的区域为firstrange
'等同Set FirstRange = .Paragraphs(1).Range
With FirstRange
.Font.Size = 22
.Font.Bold = True
.Font.Name = "黑体"
.ParagraphFormat.Alignment = wdAlignParagraphCenter '居中对齐
.ParagraphFormat.LineUnitBefore = 0.5 '段前0.5行距
.ParagraphFormat.LineUnitAfter = 1.5 '段前1.5行距
End With
Set CentRange = .Range(.Paragraphs(2).Range.Start, .Paragraphs.Last.Range.Start)
With CentRange
.Font.Size = 14
.Font.Name = "仿宋_GB2312"
.ParagraphFormat.CharacterUnitFirstLineIndent = 2 '首行缩进二个字符
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle '单倍行距
.ParagraphFormat.Alignment = wdAlignParagraphJustify '对齐方式两端对齐
End With
Set LastRange = .Paragraphs.Last.Range '设置最后一段的区域为LastRange
With LastRange
.Font.Size = 14
.Font.Name = "宋体"
.ParagraphFormat.Alignment = wdAlignParagraphRight '对齐方式右对齐
.ParagraphFormat.LineUnitBefore = 3 '段前距3行距
End With
End With
End Sub
'----------------------
'可以使用样式更好,另外,象这样的对象变量,通常定义一个MyRange 就可以了,每次刷新其Range对象范围,可以减少内存调用(三个变量与一个变量,所占内存是不一样的)
[此贴子已经被作者于2005-7-30 15:46:15编辑过] |