[英]Checkspelling on Field Range - Word VBA
我有一个受保护的文档,我可以运行以下行,但无法对文本实际运行“拼写检查”,并认为这是由于我的范围声明造成的,有人能指出什么问题吗?
例如:这将正确返回TRUE/FALSE
If CheckSpelling(theFields.Result.Text) = False Then
但我不能运行theFields.CheckSpelling
我尝试过的:
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
你不需要
Dim objWord as Object
Set objWord = GetObject(, "Word.Application")
因为你是用 Word 写的。
您想设置Options.SuggestSpellingCorrections = True
,然后使用theFields.Result.CheckSpelling
命中每个范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.