Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Spellcheck only certain form fields in a protected doc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roxy - 28 Mar 2008 19:28 GMT
Is it possible to spellcheck only certain form fields in a protected Word doc?
Below is the Macro I have so far but it runs through all the form fields
including the check boxes and I have a 40 page doc which takes almost 5 mins
for the spellchecker to run.  I have tried to use the macro in the 'on exit'
properties but that still doesn't seem to work.  Any ideas would be greatly
appreciated.
~Thanks,  Roxy

Sub SpellCheckForm()
Dim i As Integer
Dim bProtected As Boolean

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

End If

'check formfield for spelling
For i = 1 To ActiveDocument.FormFields.Count
ActiveDocument.FormFields(i).Select
#If VBA6 Then
Selection.NoProofing = False
#End If
Selection.LanguageID = wdEnglishUS
Selection.Range.CheckSpelling
Next

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="colleen"
End If
End Sub
David Sisson - 28 Mar 2008 22:33 GMT
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
Roxy - 28 Mar 2008 23:34 GMT
> You could use Range instead of Selection.
>
[quoted text clipped - 52 lines]
> Next
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ok I tried this and I get an Compile Error that reads:
Sub or function not defined.  And it highlights on the Bookmark().name =
SCY_BM1 line.  Also the
If left (FF.Name , 3) = "SCY"
then
is red, what am I doing wrong?  Below is the code as it reads currently.  
Thanks for all your help I have been struggling with this for days now.

Sub SpellCheck()

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

Bookmark(Matter).Name = SCY_BM1 'Spell Check Yes Bookmark #1
Bookmark(Respondent).Name = SCY_BM3 'Spell Check Yes Bookmark #1
Bookmark(Summary).Name = SCY_BM9 'Spell Check Yes Bookmark #1

For Each FF In aDoc.FormFields

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

With Rng
.CheckSpelling , True
End With

Next
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.