There will be times when you want to remove a particular macro from a document (or template) and there are a few ways you can do this:
1) Using the Macro dialog box
2) Using the Visual Basic Editor
Using the Macro dialog box
You can delete a macro using the Macro dialog box. Select (Tools > Macro > Macros).
Select the name of the macro you want to delete from the list and press the "Delete" button.
This will remove the macro from its corresponding code module.
Using this method will not remove any empty code modules from your VBA Project.
Using the Visual Basic Editor
You can also delete macros manually by displaying the Visual Basic Editor.
This window can be displayed by selecting (Tools > Macro > Visual Basic Editor) or by pressing (Alt + F11).
You will need to locate the Project in the Project Explorer window. This should appear in the top left corner. If you cannot see it, select (View > Project Explorer).
There should be a project there called VBAProject followed by the name of the document in brackets. Expand this project.
Select the Modules node and expand it. This will list all the code modules that are contained within this document.
You can double click on any module to display the corresponding code window.
Once you have located the macro in question, you can highlight it with the mouse and press the Delete key.
Deleting all the Macros
If you want to delete all the macros from a document then it is much easier to do this using the Visual Basic Editor.
This way you can use the shortcut menu to quickly remove a code module from the project.
Select the code module you want to delete and press the right mouse button and select "Remove Module".
You will be asked if you want to export the module first. Select "No".
© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext