开发者

MS Word VBA - select range, check spelling and accept first suggest

开发者 https://www.devze.com 2023-03-12 05:25 出处:网络
i\'d like to write a macro that selects the next word to the right of the cursor, checks its spelling and replaces an error with the fir开发者_开发问答st suggestion..

i'd like to write a macro that selects the next word to the right of the cursor, checks its spelling and replaces an error with the fir开发者_开发问答st suggestion..

can anyone with more VBA knowledge than me (..laugh) help out.

i tried the macro recorder but did not get any farther than this:

Sub FirstSuggest()
    Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
    ...
    ...

End Sub

thanks, kay


Dim r As Range
Set r = Selection.GoToNext(wdGoToSpellingError)

With r.GetSpellingSuggestions()
  If .Count > 0 Then
    r.Text = .Item(1).Name
  End If
End With
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号