|
参考了http://club.excelhome.net/thread-659228-1-1.html 这个帖子,自己写了一个宏,作用是1. 将全文的大纲级别设置为正文
2. 自动设置以“第X节”开头的标题为居中、大纲级别1级,“X、”开头的标题为居左,大纲级别2级,代码如下:- Sub 运行此宏设置二级标题格式()
- Call 全文更改为正文
- Call 循环查找一级标题并替换
- Call 循环查找二级标题并替换
- End Sub
- Sub 全文更改为正文()
- '
- '
- '
- Selection.WholeStory
- With Selection.ParagraphFormat
- .SpaceBeforeAuto = False
- .SpaceAfterAuto = False
- .OutlineLevel = wdOutlineLevelBodyText
- .WordWrap = True
- End With
- End Sub
- Sub 循环查找一级标题并替换()
- Dim I As Integer '循环执行
- For I = 1 To 100 '假设有100个,循环执行100次
- Selection.Find.ClearFormatting
- Selection.Find.Replacement.ClearFormatting
- With Selection.Find
- .Text = "(^13第[一二三四五六七八九十]{1,}节)(*^13)"
- .Replacement.Text = ""
- .Forward = True
- .Wrap = wdFindContinue
- .Format = False
- .MatchCase = False
- .MatchWholeWord = False
- .MatchByte = False
- .MatchAllWordForms = False
- .MatchSoundsLike = False
- .MatchWildcards = True
- End With
- Selection.Find.Execute ' 设置字体字号 Macro
- Selection.Font.Name = "仿宋" '字体
- Selection.Font.Bold = True '加粗
- Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
- Selection.Font.Size = 16 '字号,14=四号;16=三号……
- Selection.ParagraphFormat.OutlineLevel = wdOutlineLevel1
- Next I
- End Sub
- Sub 循环查找二级标题并替换()
- Dim I As Integer '循环执行
- For I = 1 To 100 '假设有100个,循环执行100次
- ' 查找一二三顿号开头的段落
- Selection.Find.ClearFormatting
- Selection.Find.Replacement.ClearFormatting
- With Selection.Find
- .Text = "(^13[一二三四五六七八九十]{1,}、)(*^13)"
- .Replacement.Text = ""
- .Forward = True
- .Wrap = wdFindContinue
- .Format = False
- .MatchCase = False
- .MatchWholeWord = False
- .MatchByte = False
- .MatchAllWordForms = False
- .MatchSoundsLike = False
- .MatchWildcards = True
- End With
- Selection.Find.Execute ' 设置字体字号 Macro
- Selection.Font.Name = "仿宋" '字体
- Selection.Font.Bold = True '加粗
- Selection.Font.Size = 14 '字号,14=四号;16=三号……
- Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
- Selection.ParagraphFormat.OutlineLevel = wdOutlineLevel2
- Next I
- End Sub
复制代码 目前碰到两个问题:1. 对“第X节”开头的标题无效,点击不作任何更改
2. 对“X、”开头的行,会自动设置该行和其上的一个段落为大纲二级
请各位大神指教
|
|