Rationale:
(1) I get tired of Word corrupting my templates when I have painstakingly assembled toolbars with over 600 macros on a menu-tree (*)
(2) I like to see my toolbars grow as each set of macros is added during application development, without having to manually add toolbar items while I'm coding.
(3) I pretty well am forced to do it in Excel and I think PowerPoint anyway.
The attached file holds VBA code that was tested in Excel2000, exported to BAS/CLS, then imported into Word2000, so it has a degree of mobility. (see below)
The body of the document has an example of the code I generate semi-automatically; I use a utility to list all the procedures in a project, sort away the debris and collect just the macros in a table, place the VBA code around and Fill-Down the constant stuff, then paste the VBA code into a module.
We are only a few weeks away from my annual Thank You to the lounge, but what's wrong with saying an extra one?
THANKS YOU to all those who push me forwards and give me insights into VBA and the MSOffice desktop applications.
You know who you are, and I'm glad to know you.
(*) I almost forgot to mention that the trailing parameters of the calls to the procedure "AddMacroButton" can be a string of sub-sub-sub menus; that is, you can define a real tree structure, not just a 1-level menu system.
See for example
Code: Select all
Call AddMacroButton("AutoFitAllcolumnsInWorkbook", "", lngFaceId, oToolbar, "Formatting", "Columns")
Call AddMacroButton("AutoFitAllcolumnsInWorksheet", "", lngFaceId, oToolbar, "Formatting", "Columns")
Call AddMacroButton("AutoFitAllRowsInWorkbook", "", lngFaceId, oToolbar, "Formatting", "Rows")
Call AddMacroButton("AutoFitAllRowsInWorksheet", "", lngFaceId, oToolbar, "Formatting", "Rows")