- The code in question is contained inside an automatically-running subroutine, such as an Auto_Open or Auto_Close subroutine.
- The code is not contained in a Visual Basic module, but "behind" a worksheet or the workbook itself.
You must insert a Visual Basic module into the workbook and then place the code in the new module.
To insert a Visual Basic module:
- In the Project Explorer in the Visual Basic Editor, activate the workbook that contains the code in question.
- On the Insert menu, click Module.
To edit code "behind" a worksheet or a workbook:
- Activate the Visual Basic Editor (press ALT+F11).
- In the Project Explorer window, you will see entries similar to the following:
If you double-click one of the worksheet names or ThisWorkbook, you can type code in the code window. Such code not contained within a Visual Basic module is considered to be "behind" the worksheet or
Microsoft Excel Objects
If an Auto_Open, Auto_Close, or other automatically-running subroutine is stored "behind" a worksheet or ThisWorkbook, it may not function correctly when you open or close your workbook, or when you perform an action that should cause the subroutine to run.
ID d'article : 213581 - Dernière mise à jour : 29 avr. 2008 - Révision : 1