Results 1 to 1 of 1
2003-11-26, 20:37 #1
- Join Date
- Feb 2001
- Yilgarn region of Toronto, Ontario
- Thanked 0 Times in 0 Posts
Dynamic Toolbar menu Captions (Word97+)
Here is my current (appears to work!) method for updating the caption on the sole menu item on the sole toolbar of any of my applications. Comments (especially to make the code more generic, more robust) welcomed.
My application templates are ALWAYS named with 5 characters followed by a three-digit version number (thanks Kevin!) so that whenever I open a template for modification I have an option automatically to bump up the name, from Neigh105.dot to Neigh106.dot, as an example.
Most of my applications have a toolbar, just one, with a menu item, just one, on which (menu) are stored the user macros.
Instead of seeing "Neigh" on the menu on the docked toolbar, I'd like to see the version number as well, for example "Neigh107".
Providing that the initial creation of the toolbar/menu system followed at least a naming convention of using the five-character code ("Neigh" in my examples), the code below should initialize the visible menu to show the generic name AND the three-digit version number.
<pre>' FIX THE TOOLbar menu caption
' the new caption is to be the name of this template
Dim strNewName As String
strNewName = MacroContainer.FullName ' e.g. "Neigh106"
strNewName = U.strGetName(strNewName) ' e.g. "C:GreavesProductsN91142DivNeigh106.dot"
Dim strOldName As String ' catches the old name of this template
Dim i As Integer
For i = 1 To Application.CommandBars.Count
strOldName = Application.CommandBars(i).Name ' e.g. "Neigh105"
If Left$(strOldName, 5) = Left$(strNewName, 5) Then
Application.CommandBars(strOldName).Controls(2).Ca ption = strNewName