Group: microsoft.public.word.vba.general
From: David Sisson
Date: Friday, March 28, 2008 4:33 PM
Subject: Re: Spellcheck only certain form fields in a protected doc

You could use Range instead of Selection.

Dim MyDoc As Document
Dim Rng As Range
Dim FF As FormField

Set MyDoc = ActiveDocument

'Unprotect the file
If MyDoc.ProtectionType <> wdNoProtection Then
bProtected = True
MyDoc.Unprotect Password:="colleen"
End if

For Each FF In aDoc.FormFields

Set Rng = FF.Range

With Rng
.CheckSpelling , True
End With
Next

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="colleen"
End If

'--------------
You could specifiy the formfields.
Set Rng = MyDoc.Formfields(1).Range 'Formfield Number 1
With Rng
.CheckSpelling , True
End With


You could rename your Formfield names on the ones you cant to check.
Then iterate the FFs, checking only the ones that match.


Bookmark(1).name = SCY_BM1 'Spell Check Yes Bookmark #1
Bookmark(3).name = SCY_BM3 'Spell Check Yes Bookmark #1
Bookmark(9).name = SCY_BM9 'Spell Check Yes Bookmark #1

Then

For Each FF In aDoc.FormFields

If left(FF.Name), 3) = "SCY" then
Set Rng = FF.Range

With Rng
.CheckSpelling , True
End With

Next



Safety Articles | Usenet Groups | Usenet News | Bluegrass