View Single Post
 
Old 12-17-2018, 09:32 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try it with a couple of little changes
Code:
Option Explicit
Private Sub cmdSpellCheck_Click()
    DoSpellCheck TextBox1
    MsgBox "Spelling and Grammar Check Complete"
lbl_Exit:
    Exit Sub
End Sub

Public Sub DoSpellCheck(oTxtBox As Control)
Dim oDoc2 As Document, oRng As Range
    With oTxtBox
        If Not .value = "" And Not .value = "<WhatEver>" Then
            Set oDoc2 = Documents.Add
            Set oRng = oDoc2.Range
            oRng = .value
            With oRng
                .SpellingChecked = False
                .CheckSpelling AlwaysSuggest:=True
                .CheckGrammar
                .End = .End - 1
            End With
            'Return data to the Userform
            .value = oRng.Text
            oDoc2.Saved = True
            oDoc2.Close SaveChanges:=wdDoNotSaveChanges
            Set oDoc2 = Nothing
        End If
    End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote