WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 525 reviews for our classroom and online training
Event-handling macros in Excel Visual Basic
Part four of a five-part series of blogs

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!

  1. Introduction to Handling Events in Excel VBA Code
  2. Workbook Events
  3. Events for a Particular Worksheet
  4. Bypassing Macros (this blog)
  5. Considerations for Other MS Office Application Events

This series of blogs is part of our Excel VBA online tutorial.  If you want to learn more, have a look at our classroom-based courses in VBA macros and/or Excel.

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.

Bypassing Macros

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:

Enable macros message

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!


This blog has 0 threads Add post