DocumentオブジェクトのSpellingErrorsプロパティからスペルミスとして識別される単語を取得でき、RangeオブジェクトのGetSpellingSuggestionsメソッドを使えば修正候補を取得できるので、英語のスペルミスを列挙して修正候補をコメントとして追加するマクロを考えてみました。
Option Explicit
Public Sub ChkSpellingErrors()
'英語のスペルミスを列挙して修正候補をコメントとして追加するWordマクロ
Dim rngSpellingError As Word.Range
Dim ssgn As Word.SpellingSuggestion
Dim s As String
Dim cnt As Long
'スペルミスを列挙
For Each rngSpellingError In ActiveDocument.SpellingErrors
cnt = 0 '初期化
Select Case rngSpellingError.LanguageID
'英語のみ処理
Case wdEnglishUS
'修正候補取得
For Each ssgn In rngSpellingError.GetSpellingSuggestions
If cnt < 1 Then
s = ssgn.Name
Else
s = s & "," & ssgn.Name
End If
cnt = cnt + 1
Next
'エラー箇所に修正候補をコメントとして追加
ActiveDocument.Range.Comments.Add rngSpellingError, "修正候補:" & s
End Select
Next
End Sub
■ 関連Webページ
・日本語の文法上の誤りを列挙して修正候補をコメントとして追加するWordマクロ
//www.ka-net.org/blog/?p=4510
・GetSpellingSuggestionsメソッドで文法上の誤りの修正候補は取得できない?
//www.ka-net.org/blog/?p=4517
・Wikipedia:Lists of common misspellings – Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings
















この記事へのコメントはありません。