|
- Public Sub 自动格式化()
- Dim str, i, n
- For i = 1 To ThisDocument.Paragraphs.Count - 1
- If i = 1 Then
- n = n + 1
- str = str & n & "." & ThisDocument.Paragraphs(i).Range & ThisDocument.Paragraphs(i + 1).Range
- ThisDocument.Paragraphs(i).Range = n & "." & ThisDocument.Paragraphs(i).Range
- ThisDocument.Range(ThisDocument.Paragraphs(i).Range.Start, ThisDocument.Paragraphs(i + 1).Range.End - 1).Bold = True
- Else
- If ThisDocument.Paragraphs(i - 1).Range = vbCr Then
- n = n + 1
- str = str & n & "." & ThisDocument.Paragraphs(i).Range & ThisDocument.Paragraphs(i + 1).Range
- ThisDocument.Paragraphs(i).Range = n & "." & ThisDocument.Paragraphs(i).Range
- ThisDocument.Range(ThisDocument.Paragraphs(i).Range.Start, ThisDocument.Paragraphs(i + 1).Range.End - 1).Bold = True
- End If
- End If
- Next
- ThisDocument.Paragraphs(1).Range.InsertBefore (str & vbCr)
- End Sub
复制代码
|
|