The simplest way is to have all your macros in the Normal template, so they're all automatically loaded into every doc. However, that can get cumbersome with a lot of macros.
Like Kilroy, I give each sub a very descriptive name, which can be long—clarity is the goal, eg:
Sub ReplaceGiraffeWithGorilla()
Quote:
How do you organize your code so they are reusable and easily identified ?
|
The main way I keep macros accessible & easily identified is by customizing the ribbon. I add a new tab or two, associate the key macros with buttons, and group them in ribbon sections.
When I have a lot of small routines which are part of a larger task, then the 'key macro' I mentioned will be one which calls each of the small ones—I give the key macros names which will sort at the top of the module display, in the order of execution.
Example:
Sub 1ReplaceAnimals ()
Call ReplaceGiraffeWithGorilla
Call ReplaceRhinoWithHippo
Call etc
Sub 2ReplaceBirds ()
Call ReplaceVultureWithCondor
Call ReplaceGooseWithDuck
Call etc
I have only a few macros in my Normal template, ie those I want to run every time I launch Word—eg AutoOpen & AutoNew to have the panels I want on screen from the start.
In case you don't know, macros are stored in Word templates. If you want the macros in your file system, then you have to copy & paste from the Word VBA editor. Make sure to locate the templates in a place you backup—you lose 'em, your macros are gone.
I keep most of my Office macros in separate templates, each of which is tailored to one of my main tasks. Each template contains only the macros relevant to that task. But that's just my preference.