简体   繁体   中英

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

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 first 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM