Microsoft Office Tutorials and References
In Depth Information
Using Forms Protection
the solution should run without interruption. Or, it may be that open files
should not have any macros they contain execute.
A new property was introduced in Word 2002 that allows macro security to be
adjusted while code is executing. Once it has finished, reset security to the
user's original setting. Here are the three available settings:
msoAutomationSecurityByUI
Uses the security setting specified in the
Security dialog box
¾
msoAutomationSecurityForceDisable Disables all macros in all files opened
programmatically without showing any
security alerts
¾
Wrd
msoAutomationSecurityLow
Enables all macros
This is the default value of the property.
This technique is used in Finding and
Replacing in Multiple Documents on
page 122 .
¾
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
' * * * * *¶
Private Security As Long¶
Sub AutoOpen()¶
RemoveProtection¶
SetMacroSecurity¶
'Open other documents¶
Application.AutomationSecurity = Security¶
End Sub¶
' * * * * *¶
Sub RemoveProtection()¶
ActiveDocument.Unprotect "test"¶
'Remove macro message¶
ActiveDocument.Paragraphs(1).Range.Delete¶
End Sub¶
' * * * * *¶
Sub SetMacroSecurity()¶
Security = Application.AutomationSecurity¶
Application.AutomationSecurity = msoAutomationSecurityForceDisable¶
End Sub¶
Search JabSto ::




Custom Search