PDA

View Full Version : Restore all built-in toolbars



lior03
05-29-2006, 07:02 AM
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

Jacob Hilderbrand
05-29-2006, 07:19 AM
Try this macro:


Option Explicit

Sub Macro1()

Dim CBar As CommandBar

For Each CBar In Application.CommandBars
CBar.Reset
Next

End Sub

lior03
05-29-2006, 08:01 AM
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.
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"

thanks

lucas
05-29-2006, 09:06 AM
Try this:

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

lucas
05-29-2006, 09:07 AM
I just ran your code to create the control. then used the recorder to create the line of code that deletes it.....