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 / February 2006

Tip: Looking for answers? Try searching our database.

Update Macro for Spell Check: Clarification

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kay - 08 Feb 2006 15:51 GMT
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
Charles Kenyon - 08 Feb 2006 17:33 GMT
The macro works.

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

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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

> 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
[quoted text clipped - 39 lines]
>
>   End Sub
Kay - 10 Feb 2006 01:51 GMT
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.

> The macro works.
>
[quoted text clipped - 43 lines]
> >
> >   End Sub
Charles Kenyon - 10 Feb 2006 04:14 GMT
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.
Signature

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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

> Mr. Charles,
>
[quoted text clipped - 57 lines]
>> >
>> >   End Sub
Kay - 10 Feb 2006 12:21 GMT
Thank you.  I will go over each line again to see if I can spot it.

> 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.
[quoted text clipped - 62 lines]
> >> >
> >> >   End Sub
 
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.