Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if Spellchecker was used

Status
Not open for further replies.

pfrancis

Programmer
Mar 18, 2004
19
US
I'm helping to create a test that sees if the user knows the basic functions of Word. I'm using VBA to check if certain actions were done. The one action that I am having a hard time checking for, is the spellchecker. Does anyone know how to I could set this up?
 
Try this:

Option Explicit

Sub SpellCheckereChange()

Dim CmdBar As CommandBar
Dim CmdCtl As CommandBarControl

For Each CmdBar In CommandBars
Set CmdCtl = CmdBar.FindControl(ID:=2, recursive:=True)
If Not CmdCtl Is Nothing Then CmdCtl.OnAction = "CustomSpellChecker"
Next CmdBar

Set CmdBar = Nothing
Set CmdCtl = Nothing

End Sub

Sub SpellCheckerReset()

Dim CmdBar As CommandBar
Dim CmdCtl As CommandBarControl

For Each CmdBar In CommandBars
Set CmdCtl = CmdBar.FindControl(ID:=2, recursive:=True)
If Not CmdCtl Is Nothing Then CmdCtl.OnAction = ""
Next CmdBar

Set CmdBar = Nothing
Set CmdCtl = Nothing

End Sub

Sub CustomSpellChecker()

MsgBox "You tried to use the Spell Checker"
Selection.CheckSpelling

End Sub

Anne Troy
 
I tried it. Could you explain what is supposed to happen?

Nothing happened for me. I spelledchecked both the whole document, and a selection.

I am a bit confused about the amount of processing going on, cycling through ALL of the commandbarscontrols.

Gerry
 
Sorry. Poor instructions...and code written for Excel. Tested in 2002.

Please change to read: FindControl(ID:=2566, recursive:=True)

Please FIRST RUN Sub SpellCheckereChange()

and then run a spell check.

I assume we'd put the SpellCheckereChange as the Document_open event to ensure it's going to run.

I of course had help with this, Gerry. You knew I didn't write it. :)



Anne Troy
 
Hey I know you are learning. Figured you went giving it a serious try. OK, maybe I will try again in Excel.

[love]

Gerry
 
Hee hee.

Well...apparently that ID number may change depending on what you're running. So if it doesn't work, then just run this little doo-higgy to get the ID number for your version:

Option Explicit
Sub CheckID()
Dim x As Long
x = Application.CommandBars("Standard").Controls("Spelling...").ID
MsgBox x
End Sub

Anne Troy
 
Which is why I was wondering about the checking through ALL of the commandbarscontrols, looking for a specific one. Seemed a lot of resources...

Hey, I just went for my morning walk and this eagle flew right over my head, cruisin' - could not have beem more than 5 or 6 feet above me. I looked right into its eye. WOW. They are big birds. A magic way to start the day.

Have a good one!

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top