|
以前自己编写的代码中的一段,就是用EXCEL VBA来写WORD页眉的。
- .ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
- With .Selection
- .ParagraphFormat.Alignment = wdAlignParagraphLeft
- .Range.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
- With .Font
- .Name = "宋体"
- .Size = 10
- End With
- .Text = "学号:_____ 姓名:__________" & Space(10) & jcbb & jccs & Space(2) & "总"
- .EndKey wdLine
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="numpages"
- .Fields.ToggleShowCodes
- .EndKey wdLine
- .TypeText Text:="页,第"
- .Fields.Add Range:=.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
- .TypeText Text:="page"
- .Fields.ToggleShowCodes
- .EndKey wdLine
- .TypeText Text:="页"
- .HomeKey wdLine
- .EndKey 5, 1
- .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
- End With
- .ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
复制代码 |
|