Spell check macro

A

Alan Stancliff

Currently, when I am editing a report, I often find a word not
recognized by the spell checker, but it is not one I want to add to my
dictionary. Usually, it is a patient's name. I work in hospital records.

What I have been doing is right-clicking the red-underlined word and
selecting "Ignore all."

I would like to assign a macro to a keystroke to do this to the word the
cursor is resting on. I know how to assign the macro to the keystroke,
but I'm not sure how to put together the macro to cause the spell
checker to ignore that particular word the cursor rests on.

Can anybody assist me here?

Regards,

Alan
 
J

Jay Freedman

Currently, when I am editing a report, I often find a word not
recognized by the spell checker, but it is not one I want to add to my
dictionary. Usually, it is a patient's name. I work in hospital records.

What I have been doing is right-clicking the red-underlined word and
selecting "Ignore all."

I would like to assign a macro to a keystroke to do this to the word the
cursor is resting on. I know how to assign the macro to the keystroke,
but I'm not sure how to put together the macro to cause the spell
checker to ignore that particular word the cursor rests on.

Can anybody assist me here?

Regards,

Alan

Since there is no VBA command that directly corresponds to the right-click
"Ignore All" item, you have to fake it by pretending to click the Ignore All
button on the Spelling dialog:

Sub IgnoreSpelling()
With Dialogs(wdDialogToolsSpellingAndGrammar)
SendKeys "+g"
.Execute
End With
End Sub

You might also be interested in a macro that will cancel all the ignored words
and start over:

Sub ResetIgnoreSpelling()
Application.ResetIgnoreAll
ActiveDocument.SpellingChecked = False
End Sub
 
A

Alan Stancliff

Hi Jay,

I wrote that this macro had seemed to work a bit too early, it seems. I
had tried it on a dummy document at home with only a few words in it.
When I got to work and ran it, the spell check dialog came up and then
just stopped. It seems to open the spell check dialog and then stop
there without sending the "g" or closing down the dialog.

Any suggestions?

Regards,

Alan
 
J

Jay Freedman

Hi Alan,

The SendKeys command has always been a little flaky. The problem is that it
issues a Windows command message rather than a specifically Office command, and
then depends on Windows to pass the message into the next window (dialog,
message box, whatever) that gets the focus. Sometimes Windows fails to deliver
the message (something else "eats" the message) or delivers it to the wrong
window. It simply isn't trustworthy in a production environment.

One thing that sometimes helps is to put the SendKeys command and the dialog's
..Show command on the same line of VBA code, separated by a colon. Then the VBA
engine evaluates both commands before starting to execute the first one, which
makes it run a little more quickly. But don't be surprised if it doesn't make a
difference. And if it doesn't, then my bag of tricks is empty.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top