我在WORD文档操作中碰到一个奇怪的现象:我需要设置段落行首的空格,本想设置为2个空格,用了两种方法,一种是选定全文,用替换的方法,结果不正确。二是不用替换方法,直接设置段落格式,此该当能成功。
特向高手请教。
另外说明一下,之所以要用替换的方法,是因为在我编制的另外一个宏程序中需要用到这种方法。
Sub 非替换方法() With Selection.ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .FirstLineIndent =CentimetersToPoints(0.35) .CharacterUnitFirstLineIndent = 2 .WordWrap = True End With End Sub Sub 替换的方法() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting WithSelection.Find.Replacement.ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .FirstLineIndent =CentimetersToPoints(0.35) .CharacterUnitFirstLineIndent = 2 .WordWrap = True End With With Selection.Find .Text = "?" .Replacement.Text = "^&" .Forward = True .Wrap = wdFindAsk .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.ExecuteReplace:=wdReplaceAll End Sub
|