Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro rename (Office 2003)

    I have a user who needs help - recently received new PC, he is going through all his macros. He created toolbar buttons for many of the macros so they would fit on the button. He renamed the buttons but now forgets what the macros actually are for. He wondered if there was a way to reset them all back to their original names?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro rename (Office 2003)

    The following macro will reset ALL custom toolbar buttons:

    Sub ResetCommandBarButtonCaptions()
    Dim cbr As CommandBar
    Dim ctl As CommandBarControl
    Dim strAction As String
    On Error Resume Next
    For Each cbr In Application.CommandBars
    For Each ctl In cbr.Controls
    Err.Clear
    strAction = ctl.OnAction
    If Err = 0 And Not strAction = "" Then
    ctl.Caption = strAction
    End If
    Next ctl
    Next cbr
    Set ctl = Nothing
    Set cbr = Nothing
    End Sub

    It might be a good idea to backup Normal.dot before running the macro!

  3. #3
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro rename (Office 2003)

    For this reason I made it a habit to store the modulenaam+macroname in the Tag of the controls on my custom Toolbars.
    In the Immediate window use this: CommandBars("MyBar").Controls("MyControl").Tag = "MyMacro".
    To check the name, type in the Immediate window: ?CommandBars("MyBar").Controls("MyControl").Tag

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •