[英]Checkspelling on Field Range - Word VBA
I have a protected document which I am able to run the following line, but unable to actually run "spellcheck" on the text and think it's due to my range declaration, can somebody point out whats wrong?我有一个受保护的文档,我可以运行以下行,但无法对文本实际运行“拼写检查”,并认为这是由于我的范围声明造成的,有人能指出什么问题吗?
Eg: This returns TRUE/FALSE
correctly If CheckSpelling(theFields.Result.Text) = False Then
but I can't then run theFields.CheckSpelling
例如:这将正确返回
TRUE/FALSE
If CheckSpelling(theFields.Result.Text) = False Then
但我不能运行theFields.CheckSpelling
What I have tried:我尝试过的:
Sub SpellCheckDoc()
Dim lockedFields As Long
Dim unlockedFields As New Collection
For Each theFields In ActiveDocument.Fields
If theFields.Locked = False Then
unlockedFields.Add theFields
End If
Next theFields
'Word
Dim objWord As Object
Set objWord = GetObject(, "Word.Application")
For Each theFields In unlockedFields
If CheckSpelling(theFields.Result.Text) = False Then
objWord.theFields.CheckSpelling
ActiveDocument.Range(theFields).CheckSpelling
End If
Next theFields
End Sub
You don't need the你不需要
Dim objWord as Object
Set objWord = GetObject(, "Word.Application")
since you're writing this in Word.因为你是用 Word 写的。
You want to set Options.SuggestSpellingCorrections = True
and then hit each range with a theFields.Result.CheckSpelling
.您想设置
Options.SuggestSpellingCorrections = True
,然后使用theFields.Result.CheckSpelling
命中每个范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.