Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 2010 Text Form Spell Checking working! How to set to run always on first field?

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
504
0
16
US
So after an extensive amount of research over several months, I cam across the code to finally check the text form fields in a Word Form. The only issue with it is that it won't always start at the top of the document in the text field. The code will eventually get to the field which is good.

1) is there a way to automatically start at the first field instead of somewhere else?
2) When you press the cancel button when the spell check is working, it won't cancel / end the spell checker until it has gone through the complete document. Is there a way to resolve this?
3) On occasion, the spell checker will check the same field multiple times if the ignore once button is pressed. Is there a way to prevent this?

Other than those 3 points, the code works great!

Here is the original page with the instructions as reference:
Code:

Code:
Sub spellcheck2()


If MsgBox("Would you like to spell check?", vbYesNo, "Spell Check") = vbYes Then

MsgBox ("The screen may flash while Spell Check is Running")
       
             
                Dim iCnt As Integer
            
            
             ActiveDocument.Unprotect Password:="test"
            
            
            For iCnt = 1 To ActiveDocument.FormFields.Count
                         'Select formfield
                        ActiveDocument.FormFields(iCnt).Select
                         
                        #If VBA6 Then
                             'Only Word > 2000
                            Selection.NoProofing = False
                        #End If
                         'Set Language
                        Selection.LanguageID = wdEnglishUS
                         'Run spell checker
                        Selection.Range.CheckSpelling
            
            Next
            

            
            ActiveDocument.Protect Type:=wdAllowOnlyFormFields, Noreset:=True, Password:="test"

MsgBox ("Spell Check is complete")

Else

End If




End Sub
 
Hi,

Select the first word in the document before your current process starts.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip,

Since the document is locked as a form, I am not sure as to how that can be done. Also, this form is going to suppliers and I don't think that I want to place instructions on how to do that.

Any suggestions on maybe using the count of fields to have it start at the first one always?

Thanks!
 
How about...
Code:
ActiveDocument.FormFields(1).Select

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
The index will be in order of creation. Not necessarily the same as sequence within the document.
 
Code:
Dim sFirstField As String

sFirstField = “[i]first field name[/i]”   [b]’remig, put the first field name here[/b]

ActiveDocument.FormFields(sFirstField).Select

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip,

I have some questions.

1) Since it is a legacy form field, would it be the bookmark name? (example = text13)

2) Where would I put the code in my code? I am not terribly advanced in coding and I just seem to be able to able to cobble things together and somehow make it work.

Code:
sFirstField = “first field name”   ’remig, put the first field name here

ActiveDocument.FormFields(sFirstField).Select

Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top