Microsoft Office 2000/Visual Basic Programmer's Guide |
To automatically run code when an add-in is loaded, create a Sub procedure named AutoExec in a standard module in the add-in project. Any code within this procedure runs when the add-in is loaded. To run code when an add-in is unloaded, add a Sub procedure named AutoExit. If you close and reopen Word while an add-in is loaded, the AutoExec procedure runs when you reopen Word.
Note The Document_Open event procedure doesn't run when a document is loaded as an add-in. It runs only when the document is opened directly in Word.