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 / June 2005

Tip: Looking for answers? Try searching our database.

Template spell check and security

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Helen - 15 Jun 2005 21:01 GMT
I have a large number of template forms with fill-in fields. I've embedded a
macro (below) that allows the document to be unprotected, spell checked, then
reprotected using just a single toolbar button. The manager of the division
now wants people to be unable to manually unprotect any template to stop
unauthorized tampering with the boilerplate, but still wants to be able to
spell check. I've been passwording the unprotect function, but that disables
the spell check macro. Can I modify the macro to automate the unprotect,
enter password, spell check, and invisibly reprotect with the password?

Thanks!

The code:
Sub FormsSpellCheck()
'
' FormsSpellCheck Macro
' Macro created 4/28/2004 by helenp

' If document is protected, unprotect it
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=" "
End If

' Set the language for the document.
Selection.WholeStory
Selection.LanguageID = wdEnglishUS
Selection.NoProofing = False

' Perform Spelling/Grammar check.
' If Options.CheckGrammarWithSpelling = True Then
' ActiveDocument.CheckGrammar
' Else
ActiveDocument.CheckSpelling
' End If

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

End Sub

Sub ToolsProtectUnprotectDocument()
' Macro written by helenp 11/18/2004
' Allows document to be unprotected and reprotected without resetting fields
Dim oDoc As Document
Set oDoc = ActiveDocument

On Error GoTo ErrMess
If oDoc.ProtectionType = wdNoProtection Then
With Dialogs(wdDialogToolsProtectDocument)
.noreset = True
.Show
End With
Else
oDoc.Unprotect
End If
Exit Sub

ErrMess:
MsgBox Err.Description, blInformation

End Sub

Sub ProtectForm()
' Macro written by helenp 11/18/2004
' Allows document to be unprotected and reprotected without resetting fields

If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
ActiveDocument.Unprotect
Else
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End If

End Sub

Signature

Helen

Charles Kenyon - 16 Jun 2005 01:16 GMT
See http://www.mvps.org/word/FAQs/MacrosVBA/SpellcheckProtectDoc.htm.
There are instructions at the end on how to handle password protected
documents. Note that you will also want to password protect your code.
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://www.mvps.org/word 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.

>I have a large number of template forms with fill-in fields. I've embedded
>a
[quoted text clipped - 76 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.