Roxy said:
Thank you for your speedy reply.
Is there any way you would be willing to help me with my code that I have
currently written? I could send you the document and you could look at it to
see the trouble I am having with spellchecking only certain form fields and
not the entire document. I need to figure out what language to insert after
the end of the spellcheck code to have it STOP THERE and then go on to the
next bookmark let the user enter data and so on. I have been practicing on a
1 page doc before I mess up my 40 pager that I am really writing this for.
Any help would be great I have been exhausting all my resources on the web
for the last 4 weeks on this issue
The code you have been using from the mvps web site was designed to spell
check a whole document when a *user* decides it is time to do the spell check
(by clicking on a button or some other similar input method). As a user I do
not know if I would like to have the spell check kick in after every form
field in a 40-page document... I might prefer to check the spelling in one go
at the end...
That code was not designed to be used "OnExit" from a formfield in order to
check only that formfield...
If that is what you want to do, try the following:
Dim rngField As Range
Dim i As Long
With ActiveDocument
.Unprotect
Set rngField = Selection.Bookmarks(1).Range.FormFields(1).Range
i = .Range(1, rngField.End).FormFields.Count
.Range.NoProofing = True
'.SpellingChecked = True
With rngField
.NoProofing = False
.CheckSpelling
End With
.Range.NoProofing = False
.Protect wdAllowOnlyFormFields, True
If i < .FormFields.Count Then
.FormFields(i + 1).Range.Select
End If
End With
I have to mess about with
.Range.NoProofing = True
because I did not find a way to stop the spell check at the end of the
current formfield range. It seems it wants to go on to the end of the
document...
There might be a way to control the spell checker so that it behaves and
spell checks only the targeted range. On the other hand, it would not be the
first time that a workaround is necessary because of some flaw in the Word
Object model. I decided to set the whole document to "No Proofing." You
could, instead, set the whole document to a state indicating that spell
checking has been performed:
'.SpellingChecked = True
I commented out that line in the code above. You could use it instead. I am
not sure what the pros/cons would be with using NoProofing vs. using
SpellingChecked.
Good luck!