2016-04-23 88 views
0

我想改变这一切语法错误/标点所有的语法错误,有没有办法改变这种标有绿线,没有MS字问

例如:

" ." into "." 

" ," into"," 

" :" into ":" 

"two spaces" into "single space" 

和其他任何错误,MS字把绿线下。有一种方法可以这样做,但它每次都必须要更改。

 Sub Grammercheck() 
     ActiveDocument.CheckGrammar 
     End sub 

那么还有其他方法可以改变吗?没有MS词每次问。 Reference image

+0

似乎为自动更正作业。 –

+0

...但我测试了“,”到“,”不被接受(添加按钮保持灰色)。 –

+0

@PaulOgilvie如果我使用'Selection.Find.Replacement',那么我如何将所有上述提到的情况放在一个替换中? –

回答

0

不幸的是,自动更正不接受“。”替换为“。”。但是,您可以使用下面的过程,当你与文档进行更换这些事件,例如:

Sub replaceAll() 
Dim myRange As Range 
    Set myRange = ActiveDocument.Content 
    myRange.Find.Execute FindText:=" .", ReplaceWith:=".", _ 
     Replace:=wdReplaceAll 

    Set myRange = ActiveDocument.Content 
    myRange.Find.Execute FindText:=" ;", ReplaceWith:=";", _ 
     Replace:=wdReplaceAll 
End Sub 

(示例直接取自上查找物品词VBA文档,所以“如果没有什么帮助,阅读手动!“)

+0

'Selection.Find.ClearFormatting Selection.Find.Execute FindText:=“。”,ReplaceWith:=“。”,_ 替换:= wdReplaceAll' 做这项工作非常完美。不需要添加'myRange' –

0

我想下面的代码覆盖大部分语法错误/标点,

@保罗如果有另一种简单的方式让我知道。

Sub replaceAll() 
Selection.HomeKey Unit:=wdStory 
Selection.Find.ClearFormatting 
Selection.Find.Execute FindText:=" .", ReplaceWith:=".", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=" ,", ReplaceWith:=",", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=" :", ReplaceWith:=":", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=" ;", ReplaceWith:=";", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=" ", ReplaceWith:=" ", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=" ", ReplaceWith:=" ", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:="(", ReplaceWith:="(", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=")", ReplaceWith:=")", _ 
    Replace:=wdReplaceAll 
Selection.Find.Execute FindText:=". ", ReplaceWith:=". ", _ 
    Replace:=wdReplaceAll 

End Sub 
相关问题