Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I have found macros that check every form field in the form. I need to check
only one form field because other fields contain info that will always be incorrectly spelled. Does someone have a macro that will successfully check the one field based on the bookmark name or any other reference? |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
You might adapt this to your needs:
Sub CheckMe() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Your Field BM name").Range oRng.NoProofing = False If oRng.SpellingErrors.Count 0 Then ActiveDocument.Bookmarks("Your Field BM Name").Range.Fields(1).Result.Select MsgBox "Spelling error!" End If ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub and run it on exit from the field. Aldon wrote: I have found macros that check every form field in the form. I need to check only one form field because other fields contain info that will always be incorrectly spelled. Does someone have a macro that will successfully check the one field based on the bookmark name or any other reference? |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Greg,
I tested the macro. I am not sure if it did anything. It did not provide the message nor did it highlight the misspelled words. The macro below does the job but checks any text in the document. Sub FormsSpellCheck() ' If document is protected, Unprotect it. If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect Password:="not2day" End If ' Set the language for the document. Selection.WholeStory Selection.LanguageID = wdEnglishUS ' Perform Spelling/Grammar check. If Options.CheckGrammarWithSpelling = True Then ActiveDocument.CheckGrammar Else ActiveDocument.CheckSpelling End If ' ReProtect the document. If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub If I knew more about VBA I might be able to select only the one field that needs to be checked. Aldon "Greg Maxey" wrote: You might adapt this to your needs: Sub CheckMe() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Your Field BM name").Range oRng.NoProofing = False If oRng.SpellingErrors.Count 0 Then ActiveDocument.Bookmarks("Your Field BM Name").Range.Fields(1).Result.Select MsgBox "Spelling error!" End If ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub and run it on exit from the field. Aldon wrote: I have found macros that check every form field in the form. I need to check only one form field because other fields contain info that will always be incorrectly spelled. Does someone have a macro that will successfully check the one field based on the bookmark name or any other reference? |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Aldon,
Did you change the index name "Your field BM name" to match the name of your field? Try this one: Sub CheckMeExit() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Text1").Range oRng.NoProofing = False oRng.CheckSpelling ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub Set the macro to run on exit from a field bookmarked "Text1" Aldon wrote: Greg, I tested the macro. I am not sure if it did anything. It did not provide the message nor did it highlight the misspelled words. The macro below does the job but checks any text in the document. Sub FormsSpellCheck() ' If document is protected, Unprotect it. If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect Password:="not2day" End If ' Set the language for the document. Selection.WholeStory Selection.LanguageID = wdEnglishUS ' Perform Spelling/Grammar check. If Options.CheckGrammarWithSpelling = True Then ActiveDocument.CheckGrammar Else ActiveDocument.CheckSpelling End If ' ReProtect the document. If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub If I knew more about VBA I might be able to select only the one field that needs to be checked. Aldon "Greg Maxey" wrote: You might adapt this to your needs: Sub CheckMe() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Your Field BM name").Range oRng.NoProofing = False If oRng.SpellingErrors.Count 0 Then ActiveDocument.Bookmarks("Your Field BM Name").Range.Fields(1).Result.Select MsgBox "Spelling error!" End If ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub and run it on exit from the field. Aldon wrote: I have found macros that check every form field in the form. I need to check only one form field because other fields contain info that will always be incorrectly spelled. Does someone have a macro that will successfully check the one field based on the bookmark name or any other reference? |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Greg,
I tried that and it did not work. I used portions of another macro that I found and it still does not work. This is what I last used Sub CheckMeExit() Dim oRng As Word.Range ActiveDocument.Unprotect Password:="******" Set oRng = ActiveDocument.FormFields("underlying").Range oRng.NoProofing = False If Options.CheckGrammarWithSpelling = True Then oRng.CheckGrammar Else oRng.CheckSpelling End If If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub "Greg Maxey" wrote: Aldon, Did you change the index name "Your field BM name" to match the name of your field? Try this one: Sub CheckMeExit() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Text1").Range oRng.NoProofing = False oRng.CheckSpelling ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub Set the macro to run on exit from a field bookmarked "Text1" Aldon wrote: Greg, I tested the macro. I am not sure if it did anything. It did not provide the message nor did it highlight the misspelled words. The macro below does the job but checks any text in the document. Sub FormsSpellCheck() ' If document is protected, Unprotect it. If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect Password:="not2day" End If ' Set the language for the document. Selection.WholeStory Selection.LanguageID = wdEnglishUS ' Perform Spelling/Grammar check. If Options.CheckGrammarWithSpelling = True Then ActiveDocument.CheckGrammar Else ActiveDocument.CheckSpelling End If ' ReProtect the document. If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub If I knew more about VBA I might be able to select only the one field that needs to be checked. Aldon "Greg Maxey" wrote: You might adapt this to your needs: Sub CheckMe() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Your Field BM name").Range oRng.NoProofing = False If oRng.SpellingErrors.Count 0 Then ActiveDocument.Bookmarks("Your Field BM Name").Range.Fields(1).Result.Select MsgBox "Spelling error!" End If ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub and run it on exit from the field. Aldon wrote: I have found macros that check every form field in the form. I need to check only one form field because other fields contain info that will always be incorrectly spelled. Does someone have a macro that will successfully check the one field based on the bookmark name or any other reference? |
#6
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Aldon,
It worked for me. Here is a modified version of your macro. Make sure ToolsOptionsCheck Spelling as you type is set. Sub CheckMeExit() Dim oRng As Word.Range ActiveDocument.Unprotect Password:="******" Set oRng = ActiveDocument.FormFields("underlying").Range oRng.NoProofing = False If Options.CheckSpellingAsYouType = True Then oRng.CheckSpelling Else MsgBox "You don't have your options set to check spelling as you type." End If ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub Aldon wrote: Greg, I tried that and it did not work. I used portions of another macro that I found and it still does not work. This is what I last used Sub CheckMeExit() Dim oRng As Word.Range ActiveDocument.Unprotect Password:="******" Set oRng = ActiveDocument.FormFields("underlying").Range oRng.NoProofing = False If Options.CheckGrammarWithSpelling = True Then oRng.CheckGrammar Else oRng.CheckSpelling End If If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub "Greg Maxey" wrote: Aldon, Did you change the index name "Your field BM name" to match the name of your field? Try this one: Sub CheckMeExit() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Text1").Range oRng.NoProofing = False oRng.CheckSpelling ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub Set the macro to run on exit from a field bookmarked "Text1" Aldon wrote: Greg, I tested the macro. I am not sure if it did anything. It did not provide the message nor did it highlight the misspelled words. The macro below does the job but checks any text in the document. Sub FormsSpellCheck() ' If document is protected, Unprotect it. If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect Password:="not2day" End If ' Set the language for the document. Selection.WholeStory Selection.LanguageID = wdEnglishUS ' Perform Spelling/Grammar check. If Options.CheckGrammarWithSpelling = True Then ActiveDocument.CheckGrammar Else ActiveDocument.CheckSpelling End If ' ReProtect the document. If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub If I knew more about VBA I might be able to select only the one field that needs to be checked. Aldon "Greg Maxey" wrote: You might adapt this to your needs: Sub CheckMe() Dim oRng As Word.Range ActiveDocument.Unprotect Set oRng = ActiveDocument.FormFields("Your Field BM name").Range oRng.NoProofing = False If oRng.SpellingErrors.Count 0 Then ActiveDocument.Bookmarks("Your Field BM Name").Range.Fields(1).Result.Select MsgBox "Spelling error!" End If ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub and run it on exit from the field. Aldon wrote: I have found macros that check every form field in the form. I need to check only one form field because other fields contain info that will always be incorrectly spelled. Does someone have a macro that will successfully check the one field based on the bookmark name or any other reference? |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I check spelling in a protected form? | Microsoft Word Help | |||
How do I check spelling in a text form field? | Microsoft Word Help | |||
Check box in Form Fields | Formatting Long Documents | |||
spell check form fields | Microsoft Word Help | |||
Word should let me check spelling when I am using a locked form. | Microsoft Word Help |