代码制作试卷(十)——设置页码及其样式

2022-07-14 08:19:12   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《代码制作试卷(十)——设置页码及其样式》,欢迎阅读!
页码,样式,试卷,及其,设置
试卷制作(十)



设置试卷页码格式,因为试卷一般分成两栏。在每栏下面添加页码,同时在页码前面写上学校等信息。这样看起来更具规范

'========================================================================================================================

'======================================================================================================================== Sub 设置页码()

'设置分栏页码与格式代码

Dim myRange As Range, myBK As Bookmark, myStyle As Style

Dim myString As String, myTable As Table, myCell As Cell, Lenth As Byte

myString = VBA.InputBox(prompt:="请输入你要添加的文字", Title:="添加页码文字", Default:="杨小题库试卷 ")

Lenth = Len(CStr(myString)) '在页脚中插入表格

Set myRange = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range Set myTable = myRange.Tables.Add(Range:=myRange, numrows:=1, NumColumns:=2) '设置第1个单元格的页码(1) Set myCell = myTable.Cell(1, 1) Set myRange = myCell.Range

myRange.InsertAfter myString & "=PAGE*2-1(=NUMPAGES*2)" myRange.SetRange myRange.Start + Lenth + 10, myRange.Start + Lenth + 11 Set myBK = myRange.Bookmarks.Add(Name:="myBK", Range:=myRange) Set myRange = myCell.Range

myRange.SetRange myRange.Start + Lenth + 14, myRange.Start + Lenth + 22 myRange.Fields.Add myRange, wdFieldEmpty, , False Set myRange = myCell.Range

myRange.SetRange myRange.Start + Lenth + 13, myRange.End - 3 myRange.Fields.Add myRange, wdFieldEmpty, , False Set myRange = myCell.Range

myRange.SetRange myRange.Start + Lenth + 2, myRange.Start + Lenth + 6 myRange.Fields.Add myRange, wdFieldEmpty, , False Set myRange = myCell.Range

myRange.SetRange myRange.Start + Lenth + 1, myBK.Start myRange.Fields.Add myRange, wdFieldEmpty, , False '''''''''''''''''''''''''''''''''''''

'设置第2个单元格的页码(2) Set myCell = myTable.Cell(1, 2) Set myRange = myCell.Range

myRange.InsertAfter myString & "=PAGE*2(=NUMPAGES*2)" myRange.SetRange myRange.Start + Lenth + 8, myRange.Start + Lenth + 9

1


Set myBK = myRange.Bookmarks.Add(Name:="myBK", Range:=myRange) Set myRange = myCell.Range

myRange.SetRange myRange.End - 5, myRange.End - 13 myRange.Fields.Add myRange, wdFieldEmpty, , False Set myRange = myCell.Range

myRange.SetRange myBK.End + 2, myRange.End - 3 myRange.Fields.Add myRange, wdFieldEmpty, , False Set myRange = myCell.Range

myRange.SetRange myRange.Start + Lenth + 2, myRange.Start + Lenth + 6 myRange.Fields.Add myRange, wdFieldEmpty, , False Set myRange = myCell.Range

myRange.SetRange myRange.Start + Lenth + 1, myBK.Start myRange.Fields.Add myRange, wdFieldEmpty, , False myBK.Delete

'''''''''''''''''''''''''''''''''''''''''''''''''''''' '设置表格格式

With myTable.Range .Fields.Update

.ParagraphFormat.Alignment = wdAlignParagraphCenter .Cells.VerticalAlignment = wdCellAlignVerticalCenter .Font.Size = 10

.Font.Name = "华文细黑" End With

With ActiveDocument

.ActiveWindow.View.TableGridlines = False '隐藏虚框 Set myStyle = .Styles("页眉") '修改页眉样式

myStyle.ParagraphFormat.Borders(wdBorderBottom).LineStyle = wdLineStyleNone myStyle.AutomaticallyUpdate = True End With End Sub

'========================================================================================================================

'========================================================================================================================

仁寿县黑龙滩镇杨柳小学 唐希胜

2015-10-29

2


本文来源:https://www.wddqxz.cn/ab2bb98dfbb069dc5022aaea998fcc22bcd143ed.html

相关推荐