Excel Workbook Open Event macro doesn't always run

ScottSM picture ScottSM · Mar 25, 2011 · Viewed 29k times · Source

I've got a Workbook_Open event macro (and it's in ThisWorkbook) that doesn't always run.

  • If Excel is closed and I double-click the .xls file from Windows Explorer, it does run.
  • If I launch Excel from Start/Programs (with no .xls file) and then open the file, it does run.
  • If I've already opened the file in Excel, but then close the file (leaving Excel open) and reopen it, then the macro does not run.

I've got security set to medium and I enable macros whenever it opens.

What do I need to do to get the macro to run whenever I open it, not just the first time for this Excel session?

(btw, this is Excel 2003)

Answer

Lance Roberts picture Lance Roberts · Mar 25, 2011

I thought that this was the most cogent article on this problem (which is a long-standing never explained completely erratic bug that Excel exhibits). (dead link)

In short, in many cases it's a timing thing caused because the workbook is trying to calculate stuff when it opens and that gets in the way of the Workbook_Open event. The way to test on yours to see if that it for this situation, is to first rename any UDFs or Macros called by cells so that they won't get called and see if that changes anything.