For a procedure to start automatically – such as when you open a workbook – it must be associated with a particular event of a specific object. In this case, you must create the procedure in the open event of the workbook object. Similarly, to make a procedure run when you close the workbook you must place code in the BeforeClose event of the workbook.
You might want the workbook to display a message when it is opened so that new people know what it’s for or just to say welcome back. I’m going to show you how to make it display text boxes Justas a simple example so you get an idea of it. You can use the code below to create a message box appear as you open the workbook.