H
Helen
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
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