15 Jun 2011

Fast Correction of Typos in MS Word with VBA

..I use a macro to quickly fix misspelled words. More precisely, the misspelled word is replaced by the first suggestion from the spelling checker. The macro is called by hitting "strg+shift+q" just after a typo occurred.

Download-Instructions:
To use this macro you need to download this word template and save it to your default Microsoft Office Startup folder (or wherever you store your customized templates, the path can be found in word in tools / options / save tab). If stored at the right place the keyboard shortcut macro should work whenever you open a Word file on this computer.

Code:

Sub FirstSugg()

'Author: Kay Cichini
'Date: 2012-01-17
'Info: The template was created with ms word 2003

Dim r As Range
Selection.MoveLeft Unit:=wdWord
Set r = Selection.GoToNext(wdGoToSpellingError)

With r.GetSpellingSuggestions()
  If .Count > 0 Then
    r.Text = .Item(1).Name
  Else: MsgBox ("Lacking Suggestion!")
  End If
End With

Selection.MoveRight Unit:=wdWord
End Sub 

1 comment :