S
SMOO
Good morning,
I have a template that contains 3 macro buttons. I have the template
password protected but I would still like users to be able to use the macro
buttons. I keep running into two problems:
1. The macro buttons do not work at all when the template is password
protected
2. If I protect the form and then save it and reopen it the macro buttons
again do not work. But if I reopen the document and then reprotect it (with
out a password) the macros work fine.
Here are the macros I am trying to run:
A)
Option Explicit
Sub add_page()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="summer"
End If
Selection.EndKey Unit:=wdStory
ActiveDocument.AttachedTemplate.AutoTextEntries("AddTable").Insert _
Where:=Selection.Range, RichText:=True
ActiveDocument.Fields.Update
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.Bookmarks("Notes2").Range.Fields(1).Result.Select
End Sub
B)
Sub Information()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="summer"
End If
frmInformation.Show
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End If
End Sub
C)
Sub FormsSpellCheck()
' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="summer"
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
Any guidance would be greatly appreciated!
Warm Regards,
SMOO
I have a template that contains 3 macro buttons. I have the template
password protected but I would still like users to be able to use the macro
buttons. I keep running into two problems:
1. The macro buttons do not work at all when the template is password
protected
2. If I protect the form and then save it and reopen it the macro buttons
again do not work. But if I reopen the document and then reprotect it (with
out a password) the macros work fine.
Here are the macros I am trying to run:
A)
Option Explicit
Sub add_page()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="summer"
End If
Selection.EndKey Unit:=wdStory
ActiveDocument.AttachedTemplate.AutoTextEntries("AddTable").Insert _
Where:=Selection.Range, RichText:=True
ActiveDocument.Fields.Update
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.Bookmarks("Notes2").Range.Fields(1).Result.Select
End Sub
B)
Sub Information()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="summer"
End If
frmInformation.Show
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End If
End Sub
C)
Sub FormsSpellCheck()
' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="summer"
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
Any guidance would be greatly appreciated!
Warm Regards,
SMOO