BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Want to do something when a user opens a workbook, or stop them clicking on a particular cell? You need to learn how to attach code to Excel workbook or worksheet events!
- Introduction to Handling Events in Excel VBA Code
- Workbook Events
- Events for a Particular Worksheet
- Bypassing Macros (this blog)
- Considerations for Other MS Office Application Events
Posted by Andy Brown on 22 November 2011
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Sadly (for you, as a developer) it is easily possible to bypass macros which run automatically.
Bypassing Macros by not Enabling them
When you open up any workbook containing macros, if your security level is set to Medium (the default and most sensible value), you'll see a message like this:
A typical dialog box when you open a workbook containing macros.
If your user chooses the default button to disable macros, there's not much you can do about it!
An alternative way to bypass macros is by holding down the SHIFT key just at the point that you're about to open a file.
Solutions to this Problem
If you're distributing your workbook to clients, colleagues or other third parties, there are various solutions to this problem - but none is that satisfactory:
- You can ask them nicely to enable macros in your workbook.
- You can copy the workbook into a trusted folder (but you'll need to have administrator rights to their machine to do this).
- You can digitally sign the macro (but the recipient will still be able to refuse to accept it).
Basically, there is no way of forcing a third party to run your macros - which if you think about it is as it should be!