1、I 目录 修改 word 格式 1 智能清除选区软回车(换行符) . 1 2 清除选区多余空段 . 1 3 合并选区中 “, ”结束的多余分段 . 3 4 清除选区单字节空格 . 3 5 清除选区单字节空格 . 3 6 清除选区 1 字空格 . 4 7 清除选区段首 2 字空格 . 4 8 清除选区 Tab . 4 9 增加选区空格 . 5 10 选区段首缩进 0 字 . 5 11 选区段首缩进 :2 字 . 5 12 选区段首缩进转空格 已完美 . 6 13 选区段后间距 1 行 . 6 14 选区段后间距 1 行 . 6 15 选区段后间距 1 行 . 7 16 清除选区图片 . 7 17
2、 选区硬回车转软回车 . 7 18 清除选区软回车 . 7 19 合并选区段落 . 8 20 选区空格转硬回车 . 8 21 选区标点半角转全角 . 8 22 选区标点全角转半角 .10 23 选区中文句号转半角 . 11 24 把文档第一段设置为标题 1 的格式 . 11 25 选中的文本横向居中 . 11 26 缩小字距 .12 27 增大字距 .12 28 缩小行距 .13 29 增大行距 .13 30 等高变宽 .14 31 等高变窄 .14 32 字表间距 .14 33 纵向 16 开 .15 34 插入页码 .15 35 小写金额转大写金额 .16 II 36 去掉空白行 .17
3、37 查找替换 .18 38 总结: word 自动化排版宏 .18 其它 1 调整图片大小 .22 2 转字体 .22 3 转文件格式 .23 4 文件加密 .24 5 字符替换 .24 6 替换引号 .24 7 打印为 PDF 格式文件 .25 8 朗读文本 .26 9 文献标号上标化 .26 10 箭头上方加文字 .27 11 添加参考文献格式一,参考文献在文档末尾以 1 2 3 格式排列 .27 12 添加参考文献格式二,参考文献在文档末尾以 1 2 3 格式排列,修改自格式一的代码 .28 13 返回正文 .28 14 再次引用已有参考文献 .29 15 查找被删参考文献遗留引用,
4、.29 16 统计修订的字数 .29 17 快速提取脚注内容 .30 18 从任意页面编排页码 .31 20 对文档内容进行顺序排列 .32 21 替换 Word 文档插图的超链接 .32 22 为文档的每页添加固定内容 .32 23 批量实现图片的等比例缩 .33 24 提取域代码 .33 25 完美显示图片表格的普通视图 .34 26 完美显示 图片表格的页面视图 .34 27 彻底删除页眉页脚 .35 28 切换纵横向页面 .35Word 宏代码集锦 1 修改 word 格式 1 智能清除选区软回车(换行符) Sub 智能清除选区软回车 () With Selection.Find .T
5、ext = “?l“ .Replacement.Text = “&p“ .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Fin
6、d .Text = “1l“ .Replacement.Text = “&p“ End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “l“ .Replacement.Text = “ End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 2 清除选区多余空段 Sub 清除选区多余空段 () With Selection.Find .Text = “pp“ .Replacement.Text = “p“ .Match
7、Wildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll Word 宏代码集锦 2 With Selection.Find .Text = “ppp“ .Replacement.Text = “p“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “ppp“ .Replacement.Text = “p“ .MatchWildcards = Fal
8、se End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “pp“ .Replacement.Text = “p“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “pp“ .Replacement.Text = “p“ .MatchWildcards = False End With Selection.Find.Exe
9、cute Replace:=wdReplaceAll With Selection.Find .Text = “ppp“ .Replacement.Text = “p“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “p “ .Replacement.Text = “p“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll Wi
10、th Selection.Find .Text = “pp“ .Replacement.Text = “p“ Word 宏代码集锦 3 .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “pp“ .Replacement.Text = “p“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 3 合并选区中“,”结
11、束的多余分段 Sub 合并选区多余分段 () With Selection.Find .Text = “, p“ .Replacement.Text = “, “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “、 p“ .Replacement.Text = “、 “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End
12、 Sub 4 清除选区单字节空格 Sub 清除选区单字节空格 () With Selection.Find .Text = “ “ .Replacement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 5 清除选区单字节空格 Word 宏代码集锦 4 Sub 清除选区 2 单字节空格 () With Selection.Find .Text = “ “ .Replacement.Text = “ .MatchWildcards = False End
13、 With Selection.Find.Execute Replace:=wdReplaceAll End Sub 6 清除选区 1 字空格 Sub 清除选区 1 字空格 () With Selection.Find .Text = “ “ .Replacement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 7 清除选区段首 2 字空格 Sub 清除选区段首 2 字空格 () With Selection.Find .Text = “ “ .Re
14、placement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 8 清除选区 Tab Sub 清除选区 Tab() With Selection.Find .Text = vbTab .Replacement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Word 宏代码集锦 5 9 增加选区空格 Sub 增
15、加选区空格 () With Selection.Find .Text = “ “ .Replacement.Text = “ “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 10 选区段首缩进 0 字 Sub 选区段首无缩进 () With Selection.Find .Text = “ “ .Replacement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=w
16、dReplaceAll With Selection.ParagraphFormat .LeftIndent = CentimetersToPoints(0) 左缩进 0 字符 .RightIndent = CentimetersToPoints(0) 右缩进 0 字符 .FirstLineIndent = CentimetersToPoints(0) 首行缩进点 0 公分 .CharacterUnitLeftIndent = 0 左缩进单位 0 字符 .CharacterUnitRightIndent = 0 右缩进单位 0 字符 .CharacterUnitFirstLineIndent
17、= 0 End With With Selection.ParagraphFormat .LeftIndent = CentimetersToPoints(0) 左缩进 1 字符 .RightIndent = CentimetersToPoints(0) 右缩进 2 字符 .FirstLineIndent = CentimetersToPoints(0) 首行缩进点 0.35 公分 .CharacterUnitLeftIndent = 0 左缩进单位 0 字符 .CharacterUnitRightIndent = 0 右缩进单位 0 字符 .CharacterUnitFirstLineInd
18、ent = 0 End With End Sub 11 选区段首缩进 :2 字 Sub 选区段首缩进 2 字 () Word 宏代码集锦 6 With Selection.ParagraphFormat .LeftIndent = CentimetersToPoints(0) 左缩进 1 字符 .RightIndent = CentimetersToPoints(0) 右缩进 2 字符 .FirstLineIndent = CentimetersToPoints(0.35) 首行缩进点单位公分 .CharacterUnitLeftIndent = 0 左缩进单位 0 字符 .Character
19、UnitRightIndent = 0 右缩进单位 0 字符 .CharacterUnitFirstLineIndent = 2 End With End Sub 12 选区段首缩进转空格 已完美 Sub 选区段首缩进转空格 () Selection.InsertParagraphBefore Call 选区 段首无缩进 With Selection.Find .Text = “p“ .Replacement.Text = “p “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll Sel
20、ection.Delete With Selection.Find .Text = “ p“ .Replacement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 13 选区段后间距 1 行 Sub 选区段后间距 1 行 () Selection.ParagraphFormat.FirstLineIndent = CentimetersToPoints(0) Selection.ParagraphFormat.LineUnitAfter = 1 En
21、d Sub 14 选区段后间距 1 行 Sub 选区段前段后间距半行 () Selection.ParagraphFormat.FirstLineIndent = CentimetersToPoints(0) Word 宏代码集锦 7 Selection.ParagraphFormat.LineUnitBefore = 0.5 Selection.ParagraphFormat.LineUnitAfter = 0.5 End Sub 15 选区段后间距 1 行 Sub 选区段前段后无间距 () Selection.ParagraphFormat.FirstLineIndent = Centim
22、etersToPoints(0) Selection.ParagraphFormat.LineUnitBefore = 0 Selection.ParagraphFormat.LineUnitAfter = 0 End Sub 16 清除选区图片 Sub 清除选区图片 () With Selection.Find .Text = “1“ .Replacement.Text = “ .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 17 选区硬回车转软回车 Sub 选区硬回车转
23、软回车 () With Selection.Find .Text = “p“ .Replacement.Text = “l“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub 18 清除选区软回车 Sub 清除选区软回车 () With Selection.Find .Text = “l“ .Replacement.Text = “ .MatchWildcards = True End With Word 宏代码集锦 8 Selection.Find.Execute Rep
24、lace:=wdReplaceAll End Sub 19 合并选区 段落 Sub 合并选区段落 () With Selection.Find .Text = “ “ .Replacement.Text = “ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “p“ .Replacement.Text = “l“ .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = “l“ .Replacement.Text = “ .MatchWildcards = T