Microsoft Office Tutorials and References
In Depth Information
Forcing the User to Enable Macros
Forcing the User to Enable Macros
This procedure provides a workaround to force users to enable macros in order
to use the workbook successfully.
Example file:
E025.xls
Scenario: Because of the virus risk that exists in VBA
macros, Microsoft created a security model for the Office
applications that enables users to disable them as a
preventative measure. This affects all applications that rely
on macros to function properly and frustrates developers who
need to have macros enabled for the workbook to work
successfully.
This macro uses a workaround to disable worksheets in the
workbook and displays a message warning the user that
macros need to be enabled to use the workbook successfully.
Exl
Figure 29 – Instructing the User to Enable Macros
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
' * * * * *¶
Sub ForceMacros()¶
'Variable declarations¶
Dim DummySheet As Worksheet¶
Dim OtherSheet As Object 'All sheet types¶
On Error Resume Next¶
Set DummySheet = ThisWorkbook.Worksheets("Macros disabled")¶
 
Search JabSto ::




Custom Search