我想用单词检查整个页面的这个条件。
If Options.CheckGrammarWithSpelling = True Then
Selection.Comments.Add Range:=Selection.Range
Selection.TypeText Text:="WRONG!!!"
'ActiveDocument.CheckGrammar
Else
'ActiveDocument.CheckSpelling
'Selection.Comments.Add Range:=Selection.Range
End If
答案 0 :(得分:1)
您不需要Do While循环。这是你在尝试什么?
Sub DoSpellCheckAndComment()
Dim oWord As Range
Dim StoryRange As Range
For Each StoryRange In ActiveDocument.StoryRanges
Application.CheckSpelling Word:=StoryRange
For Each oWord In StoryRange.Words
If Not Application.CheckSpelling(Word:=oWord.Text) Then
oWord.Select
oWord.Comments.Add Range:=Selection.Range, Text:="WRONG!!!"
End If
Next oWord
Next StoryRange
End Sub