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/Microsoft/Development/MS_Access/Q_20907475.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.
Microsoft Access

Avatar of undefined
Last Comment
MDauphinais1

8/22/2022 - Mon
SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
MDauphinais1

Is there anyway to limit the spell check to a specific field? It tries to spell check the entire form.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

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
MDauphinais1

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

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
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
MDauphinais1

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