|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub aaaa试卷排版_v2019_5_3()
- '使用方法:在 Word 界面,按 Alt + F8 打开宏名列表,找到本宏双击(或点击“运行”按钮)即可!也可以设置热键。
- With ActiveDocument
- '回车符/手动换行符=>段落标记
- .Content.Find.Execute "[^13^11]", , , 1, , , , , , "^p", 2
- '删除所有域
- .Fields.Unlink
- '列表编号/LISTNUM域转文本
- .ConvertNumbersToText
- '半角括号转全角(此部分酌情处理)
- ' With .Content.Find
- ' .Execute "(", , , , , , , , , "(", 2
- ' .Execute ")", , , , , , , , , ")", 2
- ' End With
- '删除空行
- Dim i As Paragraph
- For Each i In .Paragraphs
- If Asc(i.Range) = 13 Then i.Range.Delete
- Next
- '全选/清除格式/首行缩进2字符
- .Select '全选
- With Selection
- .ClearFormatting '清除格式(全部字符变为五号字体,汉字变为宋体,字母和数字变为 Times New Roman)
- '取消网格
- With .Font
- .Kerning = 0
- .DisableCharacterSpaceGrid = True
- End With
- With .ParagraphFormat
- .CharacterUnitFirstLineIndent = 2 '首行缩进2字符
- .AutoAdjustRightIndent = False
- .DisableLineHeightGrid = True
- End With
- End With
- '首行:四号/楷体/居中
- With .Paragraphs(1).Range
- .Style = wdStyleHeading1
- With .Font
- .NameFarEast = "楷体_GB2312" '如果是Win7系统,请将字体改为“楷体”(即删除“_GB2312”)
- .Size = 14 '四号(14磅)
- End With
- .ParagraphFormat.Alignment = wdAlignParagraphCenter '居中
- End With
- '次行:小三/黑体/居中/单倍行距
- With .Paragraphs(2).Range
- .Style = wdStyleSubtitle
- With .Font
- .NameFarEast = "黑体"
- .Size = 15 '小三(15磅)
- .Bold = False '不加粗(如果想加粗,删除本行即可)
- End With
- With .ParagraphFormat
- .Alignment = wdAlignParagraphCenter '居中
- .Space1 '单倍行距
- End With
- End With
- '取消第1/2段落的段落间距
- With .Range(Start:=0, End:=.Paragraphs(2).Range.End).ParagraphFormat
- .SpaceBefore = 0
- .SpaceAfter = 0
- End With
- '字母设为斜体(全文查找)
- With .Content.Find
- .ClearFormatting
- .Text = "[^1-^12^14-^47^58-^127]"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- .Font.Italic = True
- .Font.Color = wdColorRed '红色(本行代码可删除!如果不删除,打印时要设全文为黑色!)
- .Start = .End
- End With
- Loop
- End With
- '页面设置
- Dim s As Section
- For Each s In .Sections
- With s.PageSetup
- If .Orientation = wdOrientPortrait Then
- .TopMargin = CentimetersToPoints(2)
- .BottomMargin = CentimetersToPoints(2)
- .LeftMargin = CentimetersToPoints(2)
- .RightMargin = CentimetersToPoints(2)
- .PageWidth = CentimetersToPoints(21)
- .PageHeight = CentimetersToPoints(29.7)
- Else
- .TopMargin = CentimetersToPoints(2)
- .BottomMargin = CentimetersToPoints(2)
- .LeftMargin = CentimetersToPoints(2)
- .RightMargin = CentimetersToPoints(2)
- .PageWidth = CentimetersToPoints(29.7)
- .PageHeight = CentimetersToPoints(21)
- End If
- .HeaderDistance = CentimetersToPoints(1.5)
- .FooterDistance = CentimetersToPoints(1.75)
- End With
- Next
- End With
- '页码设置
- With Selection
- ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
- .ParagraphFormat.Alignment = wdAlignParagraphCenter
- NormalTemplate.AutoTextEntries("第 X 页 共 Y 页").Insert Where:=Selection.Range, RichText:=True
- ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
- .HomeKey Unit:=wdStory
- End With
- '''
- '''
- '''
- 'Cambria Math字体全部替换为 Times New Roman 字体
- '其实先前的《清除格式 .ClearFormatting》命令已经把所有西文变为 Times New Roman 字体,但是,楼主 既然要求替换字体
- '我就用下面的代码完成替换了,但是,我认为其实下面的代码是不必要的!另外,我的电脑上无此字体。
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Font.Name = "Cambria Math"
- With .Replacement
- .ClearFormatting
- .Font.Name = "Times New Roman"
- End With
- .Execute FindText:="", ReplaceWith:="", Format:=True, Replace:=wdReplaceAll
- End With
- End Sub
复制代码 |
|