应用于 Range 对象的 GetSpellingSuggestions 方法。
返回一个 SpellingSuggestions 集合,该集合代表指定区域第一个单词的建议拼写替换单词。
expression.GetSpellingSuggestions(CustomDictionary, IgnoreUppercase, MainDictionary, SuggestionMode, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10)
expression 必需。该表达式返回以上一个对象。
CustomDictionary Variant 类型,可选。或为返回 Dictionary 对象的表达式,或为自定义词典的文件名。
IgnoreUppercase Variant 类型,可选。如果为 True,则忽略全部大写的单词。如果省略此参数,则使用 IgnoreUppercase 属性的当前值。
MainDictionary Variant 类型,可选。或为返回 Dictionary 对象的表达式,或为主词典的文件名。如果不指定主词典,则 Microsoft Word 使用与该区域首字语言格式相对应的主词典。
SuggestionMode Variant 类型,可选。用来指定 Word 提出拼写建议的方式。可取下列 WdSpellingWordType 常量之一。默认值是 WdSpellword。
WdSpellingWordType 可以是下列 WdSpellingWordType 常量之一: |
wdAnagram |
wdSpellword |
wdWildcard |
CustomDictionary2 — CustomDictionary10 Variant 类型,可选。或为返回 Dictionary 对象的表达式,或为一个自定义附加词典的文件名。最多可以定义 9 个附加词典。
应用于 Application 和 Global 对象的 GetSpellingSuggestions 方法。
返回一个 SpellingSuggestions 集合,该集合代表指定单词的建议拼写替换单词。
expression.GetSpellingSuggestions(Word, CustomDictionary, IgnoreUppercase, MainDictionary, SuggestionMode, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10)
expression 必需。该表达式返回以上的一个对象。
Word String 类型,必需。将接受拼写检查的单词。
CustomDictionary Variant 类型,可选。或为返回 Dictionary 对象的表达式,或为自定义词典的文件名。
IgnoreUppercase Variant 类型,可选。如果值为 True,则忽略全部大写的单词。如果省略此参数,则使用 IgnoreUppercase 属性的当前值。
MainDictionary Variant 类型,可选。或为返回 Dictionary 对象的表达式,或为主词典的文件名。如果不指定主词典,则 Microsoft Word 使用与 Word 的语言格式或该区域首字相对应的主词典。
SuggestionMode Variant 类型,可选。用来指定 Word 提出拼写建议的方式。可取下列 WdSpellingWordType 常量之一。默认值是 WdSpellword。
WdSpellingWordType 可以是下列 WdSpellingWordType 常量之一: |
wdAnagram |
wdSpellword |
wdWildcard |
CustomDictionary2 — CustomDictionary10 Variant 类型,可选。或为返回 Dictionary 对象的表达式,或为一个自定义附加词典的文件名。最多可以定义 9 个附加词典。
如果此单词拼写正确,则 SpellingSuggestions 对象的 Count 属性返回 0(零)。
本示例查看选定内容的首字的各种拼写建议。如果建议存在,则对选定区域运行拼写检查。
If Selection.Range.GetSpellingSuggestions.Count = 0 Then
Msgbox "No suggestions."
Else
Selection.Range.CheckSpelling
End If
本示例查找单词“?ook”的各种拼写建议。建议包括对通配符“?”的替换。所有拼写建议都显示在消息框中。
Sub DisplaySuggestions()
Dim sugList As SpellingSuggestions
Dim sug As SpellingSuggestion
Dim strSugList As String
Set sugList = GetSpellingSuggestions(Word:="lrok", _
SuggestionMode:=wdSpellword)
If sugList.Count = 0 Then
MsgBox "No suggestions."
Else
For Each sug In sugList
strSugList = strSugList & vbTab & sug.Name & vbLf
Next sug
MsgBox "The suggestions for this word are: " _
& vbLf & strSugList
End If
End Sub