Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application.EnableEvents defaults to False

Tags:

excel

vba

This is happening to users with Excel 2007/2010 who are using Worksheet_Change and Worksheet_SelectionChange events that I've designed in 2013.

What seems to be happening is that when they first open the workbook, their worksheet events do not fire. I've made sure they have their options defaulted to enable macros. If I open the immediate window and run Application.EnableEvents = True then their events start firing just fine. Users with Excel 2013 don't seem to have this issue, even when opening the exact same copy of the workbook from a shared network drive.

I seem to have been able to fix this by putting Application.EnableEvents = True under the Workbook_Open event, but I wonder about this as a viable long-term solution. I'd would really rather figure out why this be happening in the first place to address it directly.

like image 758
Mike Avatar asked May 10 '16 14:05

Mike


People also ask

What is application EnableEvents false?

EnableEvents. This property can be set to False to prevent the application from raising any of its events. Do not even be tempted to use this as your code will never be the only code running and other developers will have created add-ins or code behind solutions that will rely on events being fired.

What is EnableEvents?

EnableEvents is a property in Excel VBA where you can specify whether you want events to take place when the VBA code is running or not. An event is usually attached to an object. VBA Events could include things such as activating a worksheet or saving a workbook or double-clicking on a cell.


1 Answers

I had a similar issue today on some Word VBA. And it was located in a hidden project. It turned out that the On Error event handlers we incorrectly coded by someone else. I used the AutoExec and AutoOpen macros and inserted a Stop to go into debugging mode and see what happens.

These events should fire unless you had set the EnableEvents to False in your code to begin with.

like image 127
ib11 Avatar answered Sep 18 '22 13:09

ib11