字段范围上的拼写检查-Word VBA [英] Checkspelling on Field Range - Word VBA

查看:207
本文介绍了字段范围上的拼写检查-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?

例如:这将正确返回TRUE/FALSE If CheckSpelling(theFields.Result.Text) = False Then,但是我不能再运行theFields.CheckSpelling

Eg: This returns TRUE/FALSE correctly If CheckSpelling(theFields.Result.Text) = False Then but I can't then run 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编写的.

since you're writing this in Word.

您要设置Options.SuggestSpellingCorrections = True,然后用theFields.Result.CheckSpelling击中每个范围.

You want to set Options.SuggestSpellingCorrections = True and then hit each range with a theFields.Result.CheckSpelling.

这篇关于字段范围上的拼写检查-Word VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆