Google Answers Logo
View Question
 
Q: Microsoft Word: How Can I Spell Check a Filled-In Form? ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: Microsoft Word: How Can I Spell Check a Filled-In Form?
Category: Computers > Software
Asked by: prpro-ga
List Price: $30.00
Posted: 30 Dec 2004 17:35 PST
Expires: 29 Jan 2005 17:35 PST
Question ID: 449473
I used the Form toolbar to create a form within Microsoft Word so that
I could easily fill in a survey document I created.  However, when I
try to spell-check a completely filled-in form, Word will not let me
spell-check the form boxes. Even when I unlock the toolbar, it does
not work.

This is a pain because I typed very quickly in the form boxes and need
to go back to neaten the copy.

Is there a way that I can spell-check the ENTIRE filled-in document?
Answer  
Subject: Re: Microsoft Word: How Can I Spell Check a Filled-In Form?
Answered By: answerguru-ga on 30 Dec 2004 19:14 PST
Rated:5 out of 5 stars
 
Hi prpro-ga,

You're not the first to notice this seemingly missing functionality
when working with form fields. The way to get around this is to use a
macro that includes the additional logic to check all of the fields in
addition to the rest of the document.

There is actually already a great macro available from the Microsoft
MVP group that does exactly what we need. It is available from:
http://word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm

The link above provides a detailed 'how-to', including the VBA code
used within the macro. If you aren't familiar with VBA, even reading
the comments inserted throughout the code will give you a very good
idea of what is happening.

If you don't want to deal with code and just want to confirm that the
feature actually works, you can download a sample template which
contains the macro (make sure you enable macros in Word before using
this):

http://word.mvps.org/Downloads/SpellcheckSample.zip

To try the macro: 

1. Open a new document based on the template
2. The document will open with content from the template (including
protected areas and pre-filled fields)
3. Perform a spell check and confirm that the check reveals errors in
all areas of the document

To move the macro into your template:

1. Open your template
2. Go to Tools > Macro > Macros
3. Copy the text of the macro into the template
4. Save the template
5. Each document created based on the template will now contain this macro

The full text of the macro (obtained from the downloaded template) is
available from the article hyperlink as well as the file download
referenced above. For convenience, I have also included it here (do
not include any asterisks):

********************************************************

Sub RunSpellcheck()

Dim oSection As Section, OriginalRange As Range, oDoc As Document

'If no documents open, quit macro
If Documents.Count = 0 Then
    Exit Sub
End If

Set oDoc = ActiveDocument

'Check what type of protection - if any - has been applied
Select Case oDoc.ProtectionType

    'If not protected, or if protected for tracked changes,
    'run spellchecker and quit
    '-------------
    Case wdNoProtection, wdAllowOnlyRevisions
        If Options.CheckGrammarWithSpelling Then
            oDoc.CheckGrammar
        Else
            oDoc.CheckSpelling
        End If
        Application.ScreenRefresh
        If oDoc.SpellingErrors.Count = 0 Then
            If Options.CheckGrammarWithSpelling Then
                MsgBox "The spelling and grammar check is complete", vbInformation
            Else
                MsgBox "The spelling check is complete", vbInformation
            End If
        End If
        System.Cursor = wdCursorNormal
        Exit Sub
    '-------------
    Case wdAllowOnlyComments
        'Don't want to run spellchecker if protected for comments
         Exit Sub
End Select

Set OriginalRange = Selection.Range
System.Cursor = wdCursorWait

'-------------
'-------------
'If we've got this far, it's protected for forms
'Now unprotect the document
oDoc.Unprotect
oDoc.SpellingChecked = False

'Check each section for its protection property -
'which you can get even afer unprotecting the document.
'If the section was protected, call a subroutine to spellcheck the formfields
'if it wasn't, spellcheck the section
StatusBar = "Spellchecking document ..."
For Each oSection In oDoc.Sections
    If oSection.ProtectedForForms Then
        Call CheckProtectedSection(oSection)
        If Cancelled Then
            'Boolean variable returned by CheckProtectedSection
            'procedure if user pressed Cancel buttoon
            Exit For
        End If
    Else
        If oSection.Range.SpellingErrors.Count > 0 Then
            Application.ScreenUpdating = True
            oSection.Range.CheckSpelling
            If oSection.Range.SpellingErrors.Count > 0 Then
                'User pressed Cancel button
                '(Pressing Ignore reduces the count, pressing Cancel doesn't)
                Exit For
            End If
        End If
    End If
Next oSection

'Re-protect the document
oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
OriginalRange.Select
Application.ScreenRefresh
If oDoc.Range.SpellingErrors.Count = 0 Then
    MsgBox "The spelling check is complete", vbInformation
End If

'Release variables from memory
System.Cursor = wdCursorNormal
Cancelled = False
CorrectedError = vbNullString
Set MyRange = Nothing

End Sub

Private Sub CheckProtectedSection(oSection As Section)

Dim FmFld As FormField

'check only the text formfields,
'don't check listboxes and checkboxes - this speeds up the code
Application.ScreenUpdating = False
For Each FmFld In oSection.Range.FormFields
    'Check to see if the field is a text formfield
    If FmFld.Type = wdFieldFormTextInput Then
        'Check if the field is a 'real' text field (no date, formula etc)
        If FmFld.TextInput.Type = wdRegularText Then
            'The following subroutine won't be called if Word 97 is in use
            If Not Left$(Application.Version, 1) = "8" Then
                Call TurnNoProofingOff(FmFld)
            End If
            FmFld.Range.SpellingChecked = False

            'Change the language constant in the following line if necessary;
            'when you type the = sign, a list of all supported
language constants will
            'appear, and you can choose one from the list.
            FmFld.Range.LanguageID = wdEnglishUS  'Or whichever is
appropriate for you

            'If the current form field contains errors, spellcheck the text in it
            If FmFld.Range.SpellingErrors.Count > 0 Then
                'The following condition is to allow for a Word 97
bug, which was fixed in 2000;
                'if the formfield is in a table an contains more than
1 paragraph, then
                'spellchecking it will crash Word 97
                If Left$(Application.Version, 1) = "8" _
                          And FmFld.Range.Paragraphs.Count > 1 _
                          And FmFld.Range.Tables.Count > 0 Then
                    Call Word97TableBugWorkaround(FmFld)
                    If Cancelled Then Exit Sub
                Else
                    'Set a range to the formfield's range in case the user
                    'accidentally destroys the formfield by overtyping
its entire contents
                    Set MyRange = FmFld.Range
                    Application.ScreenUpdating = True
                    FmFld.Range.CheckSpelling

                    If IsObjectValid(FmFld) Then
                        If FmFld.Range.SpellingErrors.Count > 0 Then
                            'User pressed Cancel button
                            '(Pressing Ignore reduces the count,
pressing Cancel doesn't)
                            Cancelled = True
                            Exit Sub
                        End If
                    Else
                        'If formfield was destroyed because the user
overtyped its entire contents
                        CorrectedError = MyRange.Text
                        If Len(CorrectedError) = 0 Then
                            CorrectedError = MyRange.Words(1).Text
                        End If
                        Do While Not IsObjectValid(FmFld)
                            'If formfield was destroyed when the user
corrected the spelling,
                            'reinstate it, and put the user's
correction into its result
                            ActiveDocument.Undo
                        Loop
                        FmFld.Result = CorrectedError
                    End If
                End If
                Application.ScreenUpdating = False
            End If
        End If
    End If
Next FmFld

End Sub

Private Sub TurnNoProofingOff(FmFld As FormField)
    'This subroutine is called only in Word 2000 and above
    FmFld.Range.NoProofing = False
End Sub

Private Sub Word97TableBugWorkaround(FmFld As FormField)

'Unlink formfield (convert to text)
Set MyRange = FmFld.Range
FmFld.Range.Fields(1).Unlink
Application.ScreenUpdating = True
MyRange.CheckSpelling
If MyRange.SpellingErrors.Count > 0 Then
    'User pressed Cancel button
    '(Pressing Ignore reduces the count, pressing Cancel doesn't)
    Cancelled = True
End If
CorrectedError = MyRange.Text
'Undo to reinstate the formfield
Do While Not IsObjectValid(FmFld)
    ActiveDocument.Undo
Loop
FmFld.Range.Fields(1).Result.Text = CorrectedError
Application.ScreenUpdating = False

End Sub

*****************************************************

Hopefully you were able to follow the information provided above, but
if anything is unclear please post a clarification and I'll be happy
to help.

Cheers!

answerguru-ga

Request for Answer Clarification by prpro-ga on 07 Jan 2005 00:21 PST
This past week, my computer completely died and I have had to rebuild
the system.  I plan to test this next week... so please excuse my
delay in rating the answer!

Clarification of Answer by answerguru-ga on 07 Jan 2005 07:04 PST
I completely understand - meltdowns are never any fun :(

answerguru-ga
prpro-ga rated this answer:5 out of 5 stars
Thanks, answerguru!  While I am still trying to figure out exactly how
to do this with a doc I have already created based on another
template, I know this is the right approach.  Thanks for the
thoughtful response!

Comments  
Subject: Re: Microsoft Word: How Can I Spell Check a Filled-In Form?
From: gfmaster-ga on 30 Dec 2004 18:17 PST
 
prpro,
A possible solution to stated problem is to do the following:
-Open new word document,
-Cut & paste entire survey (from ?filled-in? form to new word document)*,
-Spell check,
-Cut & paste revisions as necessary.

*The ability to do this may depend on the format the survey originally
came in. Have confirmed that method works in ?Word? format (i.e.
created ?pro-forma? document) & Adobe Reader ?.pdf? format (downloaded
sample document, pressed select text button (allowing cut & paste
function to operate), proceeded as outlined).

If method doesn?t work, please supply (thread) details of the survey in question.

Kind regards,
gfmaster

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy