忽略标记为无校对语言的文本
Ignore text marked as No Proofing language
我有一个 word 文档,其中一些文本标记为 Review/Language/Do 未检查拼写或语法。为什么我的代码没有考虑“校对”?
Sub SentenceProofing()
Dim iWords As Integer
Dim Text As String
Dim oRange As range
Set oRange = ActiveDocument.range
If Not ActiveDocument.Saved Then
ActiveDocument.Save
End If
'Set number of words
iWords = 15
With oRange.Find
.NoProofing = False
For Each MySent In oRange.Sentences
If MySent.Words.Count > iWords Then
ActiveDocument.Comments.Add _
range:=MySent, Text:="Sentence longer than 15 words"
End If
Next
End With
End Sub
试试这个:
Sub SentenceProofing()
Const iWords As Long = 15 'use Const for fixed values
Dim mySent
With ActiveDocument
If Not .Saved Then .Save
For Each mySent In .Range.Sentences
If Not mySent.NoProofing Then
If mySent.Words.Count > iWords Then
.Comments.Add Range:=mySent, _
Text:="Sentence longer than 15 words"
End If
End If
Next
End With
End Sub
我有一个 word 文档,其中一些文本标记为 Review/Language/Do 未检查拼写或语法。为什么我的代码没有考虑“校对”?
Sub SentenceProofing()
Dim iWords As Integer
Dim Text As String
Dim oRange As range
Set oRange = ActiveDocument.range
If Not ActiveDocument.Saved Then
ActiveDocument.Save
End If
'Set number of words
iWords = 15
With oRange.Find
.NoProofing = False
For Each MySent In oRange.Sentences
If MySent.Words.Count > iWords Then
ActiveDocument.Comments.Add _
range:=MySent, Text:="Sentence longer than 15 words"
End If
Next
End With
End Sub
试试这个:
Sub SentenceProofing()
Const iWords As Long = 15 'use Const for fixed values
Dim mySent
With ActiveDocument
If Not .Saved Then .Save
For Each mySent In .Range.Sentences
If Not mySent.NoProofing Then
If mySent.Words.Count > iWords Then
.Comments.Add Range:=mySent, _
Text:="Sentence longer than 15 words"
End If
End If
Next
End With
End Sub