Spell check form feilds

T

temporary

I neeed to find a way to script a macro that will
run a spellcheck only on form feilds. The document
will be protected while this is in progress
so I canot run a spellcheck on the whole document.
How can I script this macro
 
P

Peter Hewett

Hi temporary

This code will spell check the entire form, including the protected parts:

Public Sub SpellCheckProtectedForm()
With ActiveDocument
.SpellingChecked = False
.Unprotect
.CheckSpelling
If Options.CheckGrammarWithSpelling Then .CheckGrammar
.Protect wdAllowOnlyFormFields, True
End With
End Sub

HTH + Cheers - Peter
 
C

Cindy M -WordMVP-

Hi Temporary,
I neeed to find a way to script a macro that will
run a spellcheck only on form feilds. The document
will be protected while this is in progress
so I canot run a spellcheck on the whole document.
How can I script this macro?
You'll find a very complex macro for spell checking Word
forms on the word.mvps.org site.

The one Peter shows you might not work very well on the
text that's actually been typed into a form field, as the
default for form fields in most versions of Word is "do not
check spelling or grammar". It would need a line that
applies a language format to the entire document, before
checking spelling is executed. You'll find one like that in
the "Forms" section of my website.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
P

Peter Hewett

Hi Cindy M -WordMVP-

Cheers Cindy - I'll look into that.

Hi Temporary,

You'll find a very complex macro for spell checking Word
forms on the word.mvps.org site.

The one Peter shows you might not work very well on the
text that's actually been typed into a form field, as the
default for form fields in most versions of Word is "do not
check spelling or grammar". It would need a line that
applies a language format to the entire document, before
checking spelling is executed. You'll find one like that in
the "Forms" section of my website.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)

HTH + Cheers - Peter
 
P

Peter Hewett

Hi Peter Hewett

Credit to Cindy for identifying the gross deficiencies in my code (eats humble pie).
Here's the corrected version:

Public Sub SpellCheckProtectedForm()
With ActiveDocument

' Reset, otherwise spell check may not happen
.SpellingChecked = False

' Document must be unprotected or spell check wont happen
.Unprotect

' Set proofing so that the TextBox FormFields get spell checked.
' Note: DropDowns don't get spell checked
SetFFProofing True

' Spell and grammar checks
.CheckSpelling
If Options.CheckGrammarWithSpelling Then .CheckGrammar

' Make form usable again
SetFFProofing False
.Protect wdAllowOnlyFormFields, True
End With
End Sub
Private Sub SetFFProofing(ByVal boolProofing As Boolean)
Dim ffItem As Word.FormField

' To make the call to this procedure more logical we negate the value passed in
boolProofing = Not boolProofing

' Set or restore proofing state
For Each ffItem In ActiveDocument.FormFields
ffItem.Range.NoProofing = boolProofing
Next
End Sub

Call the "SpellCheckProtectedForm" procedure not "SetFFProofing".

HTH + Cheers - Peter
 
C

Charles Kenyon

See <url: http://www.mvps.org/word/FAQs/MacrosVBA/SpellcheckProtectDoc.htm>.
This is the complex macro that Cindy mentioned.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Peter Hewett > écrivait :
In this message, < Peter Hewett > wrote:

|| Hi Peter Hewett
||
|| Credit to Cindy for identifying the gross deficiencies in my code (eats
humble pie).
|| Here's the corrected version:
||
|| Public Sub SpellCheckProtectedForm()
|| With ActiveDocument
||
|| ' Reset, otherwise spell check may not happen
|| .SpellingChecked = False
||
|| ' Document must be unprotected or spell check wont happen
|| .Unprotect
||
|| ' Set proofing so that the TextBox FormFields get spell checked.
|| ' Note: DropDowns don't get spell checked
|| SetFFProofing True
||
|| ' Spell and grammar checks
|| .CheckSpelling
|| If Options.CheckGrammarWithSpelling Then .CheckGrammar
||
|| ' Make form usable again
|| SetFFProofing False
|| .Protect wdAllowOnlyFormFields, True
|| End With
|| End Sub
|| Private Sub SetFFProofing(ByVal boolProofing As Boolean)
|| Dim ffItem As Word.FormField
||
|| ' To make the call to this procedure more logical we negate the value
passed in
|| boolProofing = Not boolProofing
||
|| ' Set or restore proofing state
|| For Each ffItem In ActiveDocument.FormFields
|| ffItem.Range.NoProofing = boolProofing
|| Next
|| End Sub
||
|| Call the "SpellCheckProtectedForm" procedure not "SetFFProofing".
||
|| HTH + Cheers - Peter
||
||

The macro works great... but, from the form designer point of view, there is
one little annoying thing with it. If a form is locked, it means we do not
want users to changed the protected text. The macro, by checking the
normally protected text as well, gives users a chance to play around with
that supposedly untouchable text.... :-(

Just my 2¢
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jay Freedman

Jean-Guy Marcil said:
Bonjour,

Dans son message, < Peter Hewett > écrivait :
[snip]
The macro works great... but, from the form designer point of view,
there is one little annoying thing with it. If a form is locked, it
means we do not want users to changed the protected text. The macro,
by checking the normally protected text as well, gives users a chance
to play around with that supposedly untouchable text.... :-(

Just my 2¢

Before you release the template, mark all of the protected text as "no
proofing" and the spell checker will ignore it.
 
P

Peter Hewett

Hi Jean-Guy Marcil

Yeah - It's a interesting point and one I've considered. My rationale for checking all
the text (apart from straight forward code) was that the typos in the base template would
be corrected/marked as do not spell check before the protected mode form is put into
production. Leaving just the TextBox FormFields to through up errors.

I'll modify it so that you can pass in a boolean parameter to give the user the option of
what they want to spell check.

Good point + Cheers - Peter


Bonjour,

Dans son message, < Peter Hewett > écrivait :
In this message, < Peter Hewett > wrote:

|| Hi Peter Hewett
||
|| Credit to Cindy for identifying the gross deficiencies in my code (eats
humble pie).
|| Here's the corrected version:
||
|| Public Sub SpellCheckProtectedForm()
|| With ActiveDocument
||
|| ' Reset, otherwise spell check may not happen
|| .SpellingChecked = False
||
|| ' Document must be unprotected or spell check wont happen
|| .Unprotect
||
|| ' Set proofing so that the TextBox FormFields get spell checked.
|| ' Note: DropDowns don't get spell checked
|| SetFFProofing True
||
|| ' Spell and grammar checks
|| .CheckSpelling
|| If Options.CheckGrammarWithSpelling Then .CheckGrammar
||
|| ' Make form usable again
|| SetFFProofing False
|| .Protect wdAllowOnlyFormFields, True
|| End With
|| End Sub
|| Private Sub SetFFProofing(ByVal boolProofing As Boolean)
|| Dim ffItem As Word.FormField
||
|| ' To make the call to this procedure more logical we negate the value
passed in
|| boolProofing = Not boolProofing
||
|| ' Set or restore proofing state
|| For Each ffItem In ActiveDocument.FormFields
|| ffItem.Range.NoProofing = boolProofing
|| Next
|| End Sub
||
|| Call the "SpellCheckProtectedForm" procedure not "SetFFProofing".
||
|| HTH + Cheers - Peter
||
||

The macro works great... but, from the form designer point of view, there is
one little annoying thing with it. If a form is locked, it means we do not
want users to changed the protected text. The macro, by checking the
normally protected text as well, gives users a chance to play around with
that supposedly untouchable text.... :-(

Just my 2¢

HTH + Cheers - Peter
 

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