|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 在指定页开始插入页码() '连续页
'
' Macro1 Macro
' 宏在 2015.01.07 由 User 录制
'
p = InputBox("请输入页码起始页")
p = p - 1
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
Selection.WholeStory
Selection.Delete '删除以前的页码
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:=" if "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:="Page"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:=" > " & p & """"
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:=" = "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:="page"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="-" & p
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:=""" """" \* MERGEFORMAT "
ActiveWindow.View.ShowFieldCodes = False
End Sub
|
|