Update Macro for Spell Check: Clarification

K

Kay

Thanks to Graham for responding to my message previously. I tried your
suggestion Graham and I am still having some problems with the code. I am
not sure why, but now it not only does not update...it clears out the form
field data as well. So adding the new code seemed to negate the wd
protection code that maintains the filled in data. I am including the
code....if you can help.

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

Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing

' ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If

End Sub
 
C

Charles Kenyon

The macro works.

I suspect that a line is broken. The key is you have to have noreset applied
to the protection.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
K

Kay

Mr. Charles,

I cannot find a broken line, but am I looking for the correct thing...a red
line? I am also curious about the password protection. The macro takes off
the protection but when it puts protection back on there does not seem to be
a line of code that adds the password back in.
 
C

Charles Kenyon

By broken line, I meant a line of code that should be on one line but is
wrapped to the next line and treated as a second line.

Yes, if you have a password, you have to put it in the code when you
unprotect the document and when you reprotect it.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top