Create Macro That Runs When You Open. Right-click the database in Windows Explorer. The VBA code in this file is typically written to target whatever window is active at the point of command much like how all the commands on the Ribbon Tabs are.
Click Customize and then in the Choose commands from list select Macros. Automatically run a macro when opening a workbook. Select the newly created macro and click Run.
Simply create a subroutine called Auto_Open and place code in it or call another sub from there.
Automatically your code runs when Excel starts. In the drop-down list at the top of the Macro Builder select the action that you want to perform. Begin to type a new name for the macro called Auto_Open and click Create. In a macro that might trigger an auto macro you can use the following instruction to prevent auto macros from running.