Spell check in text form fields

K

kmewing

I'm using Word 2007 on XP but this likely applies to Word 2003 as well. I
have created a form using text form fields. I have discovered that the spell
checker does not function on text entered into the fields of a protected
document. I have verified that the spell checker is turned on, and I
verified that the spell checker does detect misspelled words if I turn off
protection and type something outside of the form fields. Does anyone know
how (or if) I can enable the spell checker for text entering into the text
form fields?
 
K

kmewing

Thanks for the reference. I did do some searching but I wasn't very
diligent. I was hoping for something simple, but I'll examine this approach
and see if I can get it to work. The article does not mention what version
of Word this applies to. The newest version mentioned is Word 2000 (one
reference that says "Word 2000 or higher"). I'll see if it works on 2007.
 
G

Graham Mayor

It works in 2007

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

kmewing

I used the example macro in this article. I installed it exactly as
instructed. When I try executing it, I get a "Compile Error: Syntax Error."
Since I'm not well-versed in Visual Basic, I'm not able to troubleshoot the
problem.

FWIW, the debugger indicates the section "Sub RunSpellcheck ( )" as the
problem.
 
G

Graham Mayor

Unfortunately we cannot see over your shoulder, so delete everything you
entered in the vba editor and replace it with the following which should
work without error, provided no lines are broken in the mail format. If your
form has a password add it between the quotes in the line
sPassword = ""

Sub RunSpellCheck()
Dim i As Integer
Dim bProtected As Boolean
Dim sPassword As String

sPassword = ""

'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'check each formfield for spelling
For i = 1 To ActiveDocument.FormFields.Count
ActiveDocument.FormFields(i).Select
#If VBA6 Then
Selection.NoProofing = False
#End If
Selection.LanguageID = wdEnglishUK
Selection.Range.CheckSpelling
Next

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, _
Password:=sPassword
End If
End Sub

If you have any difficulties with that, see
http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

If you live in the US, you might want to change the line
Selection.LanguageID = wdEnglishUK
to
Selection.LanguageID = wdEnglishUS

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

kmewing

Thanks for the suggestion. I did as you directed. This file has no password
for the protection (yet) and the language is US English, so I set these
parameters appropriately. The form has about 40 editable fields. There are
about 5 fields that accept "narrative" input, so I only applied the
spellchecker to those fields.

Ideally, I would like the spellchecker to run automatically and not be
something the user must invoke manually. Therefore, to trigger the
spellchecker, I opened up the Text Form Field Options window and set the
macro to run on exit.

When I tested the form, the spellchecker did function, but I got some
anomalous behavior:

1) When I enter text into a field and press Tab to go to the next field,
Word does not just jump to the next field as expected. Instead, it quickly
cycles through all 40 fields in the form and stops on Field #1 at the top of
the page. I must then manually click on the desired field in the middle of
the page to continue.

2) If I click on a field to select it for entering text, Word again cycles
through all 40 fields and stops at Field #1 at the top. I must then click on
the desired field a second time to select it. This behavior occurs
inconsistently. Sometimes a field will be selected with just one click;
sometimes it requires two. And the same field will respond either way at any
given time.

3) If a field has a misspelled word, and you accept a correction in the
spellchecker window, everything works fine. But, say, you want to ignore
this misspelling. If you click Ignore or just try to close the spellchecker
window, the window immediately pops back indicating the same spelling error.
It gets stuck in a loop and won't let you continue until you resolve the
misspelling. I had to hit Close-Close-Close or Ignore-Ignore-Ignore may be
10 times before the window stopped coming back. It felt like an endless loop
that I couldn't get out of.

Perhaps if I made the macro a separate manual operation, these behaviors
would not appear. I'll try that approach as well. Thanks.
 
G

Graham Mayor

You only need to run the macro once - and I would suggest running it from a
toolbar button saved in the form template.
If you had no password the macro can be run with only the change to the
language.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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