Hack 58 Keep the Macros Dialog Box Tidy![]() ![]() preventing it from displaying some of your macros.When developing a macro, it's often best to split the macro into several small parts, each responsible for performing some part of the overall action. This makes the macro easier to write, easier to debug, andbest of alleasier to reuse.The downside to this strategy is that the number of macros in the Macros dialog box (Tools balloons, making it hard to find the one you need amid the clutter. True, you can assign macros to toolbars or menu buttons [Hack #1], but if you use the macros only occasionally, you may not want to clutter up your toolbars or menus with them either.Here are two things you can do to keep that dialog neat. 7.3.1 Name Macros Clearly and ConsistentlyIf your Macros dialog box is full of macros with names like test, fixer, and mymacro, you'll have a much more difficult time finding what you need than if you use descriptive names like DeleteAllHyperlinks or SetLandscapeMargins. Practically speaking, your macro names can be as long as you want, so use the space.Plus, if you use the above naming convention (starting each word in the name with a capital letter) and assign the macro to a toolbar button, Word will separate the words in the ToolTip that appears when you hover the mouse over the button. For example, Figure 7-3 shows one of the macros used to write the manuscript for this book. Figure 7-3. When you use capital letters to start new words in a macro name, Word automatically inserts spaces between them in the ToolTip text![]() 7.3.2 Hide Macros from the Macros Dialog BoxIf you write a procedure that either requires an input value to run or returns an output value when it finishes (or both), the procedure will not appear in the Macros dialog box. From the Word interface alone, there is no way for the macro to get the input it needs or handle the output it provides. For that, you need additional macro code.For example, the following two procedures will not appear in the Macros dialog box: Sub ComplimentMe(sName as String)Thus, to keep a macro out of the Macros dialog box, you can trick it into thinking it needs a value to run by using an Optional argument: Sub SuperSecretMacro(Optional bFakeInput As Boolean)Now the only way to run this macro is from another macro, as with the following code: Sub ShowSecretMacro( )Microsoft uses this particular technique extensively in the Office Wizards to keep the code from appearing in the Macros dialog. |