|
请 楼主 将最后面提取目录后的第 2 页缩小字符间距,以使制表符充满一行。
- Sub aaaa_LoopPara_GetTitle()
- Dim j As Long, s As String, n&
- With ActiveDocument
- '倒序循环遍历所有段落
- For j = .Paragraphs.Count To 1 Step -1
- With .Paragraphs(j).Range
- .Font.ColorIndex = wdRed
- If .Font.NameFarEast = "黑体" Then
- If Len(.Text) > 1 Then
- .Characters.Last.InsertBefore Text:=vbTab & .Information(wdActiveEndPageNumber)
- End If
- End If
- End With
- Next
-
- '循环遍历所有段落
- Dim i As Paragraph
- For Each i In .Paragraphs
- If i.Range Like "*" & vbTab & "[0-9]" & vbCr Or i.Range Like "*" & vbTab & "[0-9][0-9]" & vbCr Then
- i.Range.Font.ColorIndex = wdBlue
- s = s & i.Range
- n = n + 1
- End If
- Next
- .Content.InsertAfter Text:=vbCr & "*********************" & vbCr & "目录" & vbCr & s
- .Characters.Last.Delete
-
- .Range(Start:=.Paragraphs(.Paragraphs.Count - n + 1).Range.Start, _
- End:=.Content.End).Select
-
- With Selection
- .Font.ColorIndex = wdBlue
- .MoveStart 4, -1
-
- '取消首行缩进
- With .ParagraphFormat
- .CharacterUnitFirstLineIndent = 0
- .FirstLineIndent = CentimetersToPoints(0)
- End With
-
- With .Paragraphs(1).Range
- With .ParagraphFormat
- .SpaceBefore = 12
- .SpaceAfter = 12
- .Alignment = wdAlignParagraphCenter
- End With
- .Characters(1).InsertAfter Text:=Space(4)
- End With
-
- '制表位
- .ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(15.04) _
- , Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderDots
- End With
- End With
- End Sub
复制代码 |
|