Sometimes you wonder if the folks up at Redmond are laughing at us behind our backs. Really, do they deliberately set out to confuse us or are they just that plain disorganised?
Today my quandary involves Auto_Open and AutoOpen. These are two special macro names. The first, Auto_Open is Excel’s special named macro that runs automatically when the workbook containing it is opened. AutoOpen is the Word equivalent. It makes no sense that one has an underscore and the other doesn’t – it just makes life for us VBA folk a little more confusing than it should be.
The other macros Auto_Close and AutoClose work the same way, Auto_Close is the Excel macro name – call a macro by this name and save it in your workbook and it will run whenever you close the workbook. In Word, the name is AutoClose.
To add to the confusion, PowerPoint doesn’t support either of the naming conventions, in fact, you can’t create auto running macros in PowerPoint the same way you do in Word and Excel. The workaround is cumbersome, you need to create a PowerPoint add-in that includes the Auto_Open subroutine. Load the Add-in and PowerPoint will run the code in Auto_Open it loads and ditto for subroutine called Auto_close – it runs when the add-in is unloaded – which happens automatically when you exit PowerPoint. Learn more about how to do this in this KnowledgeBase article.
Thanks Redmond, we are now officially confused!