我懂konggs的意思,我的代码是为规范别人在对位方面排得不规范的文档用的,我简化了代码:
Sub 选中对位4项() ' '删除行首空格 Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^13[ , ?]{1,100}" .Replacement.Text = "^p" .Forward = True .Wrap = wdFindStop .Format = True .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "^t" .Replacement.Text = " " .Forward = True .Wrap = wdFindStop .Format = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.ParagraphFormat.TabStops.ClearAll Selection.Find.Replacement.ParagraphFormat.TabStops.Add Position:= _ CentimetersToPoints(4.26), Alignment:=wdAlignTabLeft, Leader:= _ wdTabLeaderSpaces Selection.Find.Replacement.ParagraphFormat.TabStops.Add Position:= _ CentimetersToPoints(7.78), Alignment:=wdAlignTabLeft, Leader:= _ wdTabLeaderSpaces Selection.Find.Replacement.ParagraphFormat.TabStops.Add Position:= _ CentimetersToPoints(11.3), Alignment:=wdAlignTabLeft, Leader:= _ wdTabLeaderSpaces With Selection.Find .Text = "[ , ]@([B-D])[.,.]" .Replacement.Text = "^t\1." .Forward = True .Wrap = wdFindStop .Format = True .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "[ , ]@([(,(])([B-D])([),)])" .Replacement.Text = "^t\1\2\3" .Forward = True .Wrap = wdFindStop .Format = True .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "A." .Replacement.Text = "A." .Forward = True .Wrap = wdFindStop .Format = True End With Selection.Find.Execute Replace:=wdReplaceAll
End Sub
我试过多次,先选中要有4个选项的部分,再运行,如版面不同于16K,再继续调整制表位至合适位置即可。无需再另行设计菜单供调整制表位。 |