PDA

View Full Version : Solved: Unable to delete custom toolbar created in excel 2003.



kishlaya
07-10-2009, 02:00 AM
I have a toolbar which i created in excel 2007. now it comes as a custom toolbar in the Addin ribbon in excel 2007. the procedure for creating this i have put in the Workbook_open module so that whenever this particular workbook is open the button is available. but now i am not able to delete the the button . i am looking for some code to put in workbook_beforeclose which will delete the code the button as soon as i close the workbook since each time i open the workbook it adds another button.
the code for creating the button is
Sub CreateMenubar()
On Error Resume Next
Dim iCtr As Long
Dim MacNames As Variant
Dim CapNamess As Variant
Dim TipText As Variant

With Application.CommandBars.Add
.Name = "IP"
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

With .Controls.Add(Type:=msoControlButton)
.OnAction = "wizard"
.Caption = "IP Report Generation"
.Style = msoButtonIconAndCaption
.FaceId = 7

End With

End With
End Sub

Sub wizard()
frmTool.Show False
End Sub

thanks in advance
Regards,
Kishlaya

Bob Phillips
07-10-2009, 02:14 AM
On Error Resume Next
Application.Commandbars("IP").Delete
On Error Goto 0

kishlaya
07-10-2009, 03:06 AM
Dear XLD
I have already tried that, but it does not delte the custom toolbar while closing the workbook. it istill creating new buttons whenever i open the workbook
Kishlaya

Bob Phillips
07-10-2009, 03:39 AM
Is your other code called by Workbook_Open?

kishlaya
07-10-2009, 03:44 AM
yes that is in workbook_open module.

Bob Phillips
07-10-2009, 03:50 AM
Then it will recreate it every time that you open the workbook.