1、Word宏代码集锦Word宏代码集锦一、修改word格式:1、 智能去除选区软回车换行符Sub 智能去除选区软回车() .Text = ?l .Replacement.Text = &p .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selec
2、tion.Find.Execute Replace:=wdReplaceAll .Text = 1l .Replacement.Text = &p End With Selection.Find.Execute Replace:=wdReplaceAll .Text = l .Replacement.Text = End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub2、 去除选区多余空段Sub 去除选区多余空段() .Text = pp .Replacement.Text = p .MatchWildcards = False
3、 End With Selection.Find.Execute Replace:=wdReplaceAll .Text = ppp .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = ppp .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = pp .Replaceme
4、nt.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = pp .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = ppp .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=
5、wdReplaceAll .Text = p .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = pp .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = pp .Replacement.Text = p .MatchWildcards = False End With
6、Selection.Find.Execute Replace:=wdReplaceAllEnd Sub3、 合并选区中“,完毕的多余分段Sub 合并选区多余分段() .Text = ,p .Replacement.Text = , .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = 、p .Replacement.Text = 、 .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplac
7、eAllEnd Sub4、 去除选区单字节空格Sub 去除选区单字节空格() .Text = .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub5、 去除选区单字节空格Sub 去除选区2单字节空格() .Text = .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub6、 去除选区1
8、字空格Sub 去除选区1字空格() .Text = .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub7、 去除选区段首2字空格Sub 去除选区段首2字空格() .Text = .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub8、 去除选区TabSub 去除选区Tab() .Tex
9、t = vbTab .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub9、 增加选区空格Sub 增加选区空格() .Text = .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub10、 选区段首缩进0字Sub 选区段首无缩进() .Text = .Replacement.Text
10、= .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .LeftIndent = CentimetersToPoints(0) 左缩进0字符 .RightIndent = CentimetersToPoints(0) 右缩进0字符 .FirstLineIndent = CentimetersToPoints(0) 首行缩进点0公分 .CharacterUnitLeftIndent = 0 左缩进单位0字符 .CharacterUnitRightIndent = 0 右缩进单位0字符 .Ch
11、aracterUnitFirstLineIndent = 0 End With .LeftIndent = CentimetersToPoints(0) 左缩进1字符 .RightIndent = CentimetersToPoints(0) 右缩进2字符 .CharacterUnitLeftIndent = 0 左缩进单位0字符 .CharacterUnitRightIndent = 0 右缩进单位0字符 .CharacterUnitFirstLineIndent = 0 End WithEnd Sub11、 选区段首缩进:2字Sub 选区段首缩进2字() .LeftIndent = Cen
12、timetersToPoints(0) 左缩进1字符 .RightIndent = CentimetersToPoints(0) 右缩进2字符 .FirstLineIndent = CentimetersToPoints(0.35) 首行缩进点单位公分 .CharacterUnitLeftIndent = 0 左缩进单位0字符 .CharacterUnitRightIndent = 0 右缩进单位0字符 .CharacterUnitFirstLineIndent = 2 End WithEnd Sub12、 选区段首缩进转空格已完美Sub 选区段首缩进转空格() Call 选区段首无缩进 .T
13、ext = p .Replacement.Text = p .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll .Text = p .Replacement.Text = .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub13、 选区段后间距1行Sub 选区段后间距1行() Selection.ParagraphFormat.FirstLineIndent = Centime
14、tersToPoints(0) Selection.ParagraphFormat.LineUnitAfter = 1End Sub14、 选区段后间距1行Sub 选区段前段后间距半行() Selection.ParagraphFormat.FirstLineIndent = CentimetersToPoints(0)End Sub15、 选区段后间距1行Sub 选区段前段后无间距() Selection.ParagraphFormat.FirstLineIndent = CentimetersToPoints(0) Selection.ParagraphFormat.LineUnitBefore = 0 Selection.ParagraphFormat.LineUnitAfter = 0End Sub16、 去除选区图片Sub 去除选区图片() .Text = 1 .Replacement.Text = .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAllEn
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1