View Single Post
 
Old 12-15-2015, 08:02 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The difficulty with creating a function to perform an autocorrect on a text is in determining what to autocorrect. Auto correct entries can be longer than a word and can include punctuation which throws out the potential word count. The only solution I can see would be to select the text you wish you check against the autocorrect list and then run the macro - something like
Code:
Sub ApplyAutoCorrect()
Dim i As Long
Dim orng As Range
    Set orng = Selection.Range
    orng.MoveStartWhile Chr(32)
    orng.MoveEndWhile Chr(32), wdBackward
    If Len(orng) > 0 Then
        For i = 1 To Word.Application.AutoCorrect.Entries.Count
            If orng.Text = Word.Application.AutoCorrect.Entries(i).Name Then
                Word.Application.AutoCorrect.Entries(i).Apply orng
                Exit For
            End If
        Next i
    End If
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote