Link to home
Start Free TrialLog in
Avatar of MDauphinais1
MDauphinais1

asked on

MS Access Text Box Spell Check

I want to perform spell check on a specific text box on command click. I found this question which gave me the answer:
https://www.experts-exchange.com/questions/20907475/spell-check.html

So I have this code:

    Dim X As Object
    CheckWhat.SetFocus
    Set X = CreateObject("Word.Application")
    X.Visible = False
    X.Documents.Add
    X.Selection.Text = CheckWhat.Text
    X.ActiveDocument.CheckSpelling
    CheckWhat.Text = X.Selection.Text
    MsgBox "Spell check is complete.", vbOKOnly, "Spell Check Complete"
    X.ActiveDocument.Close savechanges:=wdDoNotSaveChanges
    X.Quit
    Set X = Nothing

Which works great. Except, if the user clicks Cancel on the spell check window it dumps into word showing the text from the text box. How can I prevent this? I want Cancel to just cancel, do nothing else, show nothing else.
SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MDauphinais1
MDauphinais1

ASKER

Is there anyway to limit the spell check to a specific field? It tries to spell check the entire form.
Well ... it should work like this (and does for me):

Say you are in a text box that you want to spell check the text in that box. So, then you click the button.  The first line of code (previouscontrol) moves the focus back to that text box ... and then Spell Check is run.  It should only check that text box.

mx
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahh ... since I pointed out that

DoCmd.RunCommand accmdSpelling

is a *lot* simpler than the Word approach ... and in fact you are using this, a few pts are in order here, no?

mx
You did have part of the answer you are correct. I will give you a few bones.