Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Workbook Open Event macro doesn't always run

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)

like image 981
ScottSM Avatar asked Mar 25 '11 21:03

ScottSM


1 Answers

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.

like image 175
Lance Roberts Avatar answered Sep 24 '22 03:09

Lance Roberts