Share via

Macro cleanup

Anonymous
2016-04-04T17:30:03+00:00

I want to cleanup the macros I have in two dotx templates. However most of them are stored in Normal.dotm and therefore appear in all the templates. How can I clean them up so only the macros needed for a particular template only appear in that template?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Stefan Blom 342.4K Reputation points MVP Volunteer Moderator
    2016-04-04T19:43:52+00:00

    Use the Visual Basic Editor to delete macros that you want to get rid of. Press Alt+F11 to display the Editor. Click View | Project Explorer and double-click Normal to expand it. Click the Module where the macros are saved. You can select and delete anything that you want to get rid of, even whole modules (but not any of the built-in ones).

    To delete macros in other templates, you have to open them first.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2016-04-04T20:36:42+00:00

    There's some fuzziness behind the sentence "However most of them are stored in Normal.dotm and therefore appear in all the templates."

    A macro that is stored in Normal.dotm is available in documents based on other templates, but those macros are not "in" the other templates.

    If you want certain macros to be available only in documents based on a specific template, then those macros must be stored in that template and not in Normal.dotm.

    There are a couple of ways to move macros from Normal.dotm to another template.

    • Open the destination template or a document based on it, and open the VBA editor. Expand both the Normal project and the destination template's project in the Project pane. Then
      • Drag the module containing the macros from the Normal project and drop it on the destination project. This copies the module, so then you'll have to right-click the module in Normal and remove it.  OR...
      • Right-click the module in Normal and choose to export it to a .bas file (and a .frm file if it contains a userform). Then import the file(s) into the destination project.  OR...
      • Create a new module in the destination project. Cut the code text from Normal's module and paste it in the destination. Remove the now-empty module from Normal.

    OR...

    • Open the destination template or a document based on it. Press F8 to open the Macros dialog, and click the Organizer button. The Organizer dialog opens with the Macro Project Items tab visible. The right side shows the list of modules in the Normal.dotm template. If the left side shows the current document, open the "Macro Project Items available in" dropdown and choose the destination template. Then:
      • Select one or more (multiple selection while holding down Ctrl) modules in Normal.dotm.
      • Click the Copy button.
      • While the modules in Normal are still selected, click the Delete button.

    Was this answer helpful?

    0 comments No comments