|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
每次都要在底部居中插入页码,首行缩进并批量删除空行,这个过程代码怎么写?朋友帮我写了一个,很好。不过页眉线不要,文末多了一个1,不知道怎么改进,谢谢。Sub d2()
Dim i As Paragraph, n As Integer
Application.ScreenUpdating = False
For Each i In ActiveDocument.Paragraphs
If Len(i.Range) = 1 Then
i.Range.Delete
n = n + 1
End If
Next
MsgBox "共删除空白段落" & n & "个"
With ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary)
Set rng = .Range
rng.Text = "第 "
rng.Collapse wdCollapseEnd
ActiveDocument.Fields.Add rng, wdFieldPage, "Page"
Set rng = .Range
rng.Collapse wdCollapseEnd
rng.Text = " 页,共 "
rng.Collapse wdCollapseEnd
ActiveDocument.Fields.Add rng, wdFieldNumPages, "Pages"
Set rng = .Range
rng.Collapse wdCollapseEnd
rng.Text = " 页 "
.Range.Fields.Update
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
ActiveDocument.Content.ParagraphFormat.CharacterUnitFirstLineIndent = 2
Application.ScreenUpdating = True
End Sub
|
|