|
* 同一页面设置双栏页码,适用于试卷等分栏文档。本宏于 Word2003 下运行通过。
- Sub 双栏页码()
- ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
- ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
- With Selection
- .Tables(1).Style = "普通表格"
- .Tables(1).Select
- .ParagraphFormat.Alignment = wdAlignParagraphCenter
- .HomeKey Unit:=wdLine
- .TypeText Text:="第"
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="="
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="Page"
- .MoveRight Unit:=wdCharacter, Count:=2
- .TypeText Text:="*2-1"
- .Fields.ToggleShowCodes
- .EndKey Unit:=wdLine
- .TypeText Text:="页,共"
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="="
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="NumPages"
- .MoveRight Unit:=wdCharacter, Count:=2
- .TypeText Text:="*2"
- .Fields.ToggleShowCodes
- .EndKey Unit:=wdLine
- .TypeText Text:="页"
- .MoveRight Unit:=wdCell
- .TypeText Text:="第"
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="="
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="Page"
- .MoveRight Unit:=wdCharacter, Count:=2
- .TypeText Text:="*2"
- .Fields.ToggleShowCodes
- .EndKey Unit:=wdLine
- .TypeText Text:="页,共"
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="="
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="NumPages"
- .MoveRight Unit:=wdCharacter, Count:=2
- .TypeText Text:="*2"
- .Fields.ToggleShowCodes
- .EndKey Unit:=wdLine
- .TypeText Text:="页"
- End With
- ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
- ActiveWindow.View.TableGridlines = False
- End Sub
复制代码 |
|