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.Applica tion")
X.Visible = False
X.Documents.Add
X.Selection.Text = CheckWhat.Text
X.ActiveDocument.CheckSpel ling
CheckWhat.Text = X.Selection.Text
MsgBox "Spell check is complete.", vbOKOnly, "Spell Check Complete"
X.ActiveDocument.Close savechanges:=wdDoNotSaveCh anges
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.
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.Applica
X.Visible = False
X.Documents.Add
X.Selection.Text = CheckWhat.Text
X.ActiveDocument.CheckSpel
CheckWhat.Text = X.Selection.Text
MsgBox "Spell check is complete.", vbOKOnly, "Spell Check Complete"
X.ActiveDocument.Close savechanges:=wdDoNotSaveCh
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
You did have part of the answer you are correct. I will give you a few bones.
ASKER