Consulting

Results 1 to 5 of 5

Thread: Restore all built-in toolbars

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    Restore all built-in toolbars

    hello
    during the course of my work i have added many icons to toolbars such as standard or formating. how can i restore the builtin toolbars to there original position?. could it be doen at one stroke?
    thanks
    moshe

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this macro:

    [vba]
    Option Explicit

    Sub Macro1()

    Dim CBar As CommandBar

    For Each CBar In Application.CommandBars
    CBar.Reset
    Next

    End Sub
    [/vba]

  3. #3
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    hello
    i am sorry for being a jerk.
    the following macro adds an icon to the standard toolbar.
    how can i make sure it will add it only once no matter how many time i shall execute the macro.
    [VBA]On Error GoTo errhandler
    With Application.CommandBars("formatting").Controls.Add(before:=3)
    .Caption = "cell's number format"
    .FaceId = 580
    .Style = msoButtonIcon
    .OnAction = "numberformation"
    .BeginGroup = True
    End With
    Exit Sub
    errhandler:
    MsgBox " the icon already appear in toolbar"
    [/VBA]
    thanks
    moshe

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Try this:
    [VBA]
    Application.CommandBars("Formatting").Controls(3).delete
    With Application.CommandBars("formatting").Controls.Add(before:=3)
    .Caption = "cell's number format"
    .FaceId = 580
    .Style = msoButtonIcon
    .OnAction = "numberformation"
    .BeginGroup = True
    End With
    Exit Sub
    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I just ran your code to create the control. then used the recorder to create the line of code that deletes it.....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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