如何优化这段添加页码的代码
时间:2010-08-09
来源:互联网
Sub 添加页码()
' 宏在 2010-8-9 由 tangqingfu 录制
Application.ScreenUpdating = False
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
ActiveDocument.AttachedTemplate.AutoTextEntries("- 页码 -").Insert Where:= _
Selection.Range, RichText:=True
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Application.ScreenUpdating = True
End Sub
作者: tangqingfu 发布时间: 2010-08-09
作者: shyrick 发布时间: 2010-08-09
能否帮忙一下?
作者: tangqingfu 发布时间: 2010-08-09
代码:
Sub tjym()' 宏在 2010-8-9 由 kqbt 录制
With ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers
.Add PageNumberAlignment:=wdAlignPageNumberCenter, FirstPage:=True
.NumberStyle = wdPageNumberStyleNumberInDash
End With
End Sub
作者: kqbt 发布时间: 2010-08-09
作者: tangqingfu 发布时间: 2010-08-09
引用:
原帖由 kqbt 于 2010-8-9 15:31 发表Sub tjym()
' 宏在 2010-8-9 由 kqbt 录制
With ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers
.Add PageNumberAlignment:=wdAlignPageNumberCenter, FirstPage:=True
.N ...
如果添加的页码为“第X页 共Y页”格式,常量应如何修改?
作者: tangqingfu 发布时间: 2010-08-09
引用:
原帖由 tangqingfu 于 2010-8-9 22:51 发表请教kqbt兄:
如果添加的页码为“第X页 共Y页”格式,常量应如何修改?
代码:
Sub tjym()Dim Rng As Range
Set Rng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
Rng.ParagraphFormat.Alignment = wdAlignParagraphCenter
NormalTemplate.AutoTextEntries("第 X 页 共 Y 页").Insert Where:=Rng, RichText:=True
End Sub
作者: kqbt 发布时间: 2010-08-10
作者: tangqingfu 发布时间: 2010-08-10
作者: linchangh 发布时间: 2010-08-10

作者: SSJJWW 发布时间: 2010-11-01
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28