Share via


Running Code when a Word Add-in Is Loaded or Unloaded

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

To run code automatically 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 Microsoft® Word while an add-in is loaded, the AutoExec procedure runs when you reopen Word.

Note   The Document_Open event procedure does not run when a document is loaded as an add-in. It runs only when the document is opened directly in Word.

See Also

Word Add-ins | Creating a Word Add-in | Loading a Word Add-in