Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an add-in. when it is selected from the add-ins list, a toolbar
button shows up on the formatting toolbar thanks to some code donated to me. however there was also some code to get rid of the toolbar button when the add-in was deselected and it does not work properly. can someone help me debug this and help me get rid of this button when the add-in is closed. thank you. Dim sMenu As String Private Sub Workbook_BeforeClose(Cancel As Boolean) sMenu = "myButton" On Error Resume Next Application.CommandBars("Formatting").Controls("Ma rginCalculator").Delete On Error GoTo 0 End Sub Private Sub Workbook_Open() Dim oCB As CommandBar Dim oCtl As CommandBarControl Dim newMenu As Object 'CommandBarControl Dim ctrlButton As Object 'CommandBarControl sMenu = "Margin Calculator" On Error Resume Next Application.CommandBars("Formatting").Controls(sMe nu).Delete On Error GoTo 0 Set oCB = Application.CommandBars("Formatting") Set oCtl = oCB.Controls.Add(Type:=msoControlButton, temporary:=True) With oCtl .BeginGroup = True .FaceId = 652 .Style = msoButtonIconAndCaption .OnAction = "ShowCalculator" 'SHOWS USERFORM ASSOCIATED WITH ADD-IN End With SetEnterDefault 'CODE TO MAKE A CERTAIN BUTTON DEFAULT=TRUE End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your code to remove is correct - if the name of the control is
"MarginCalculator" without a space. To check, just see what the tooltip is on the button. That is the name of the control. Bob Flanagan Macro Systems http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "Spencer Hutton" wrote in message ... I have an add-in. when it is selected from the add-ins list, a toolbar button shows up on the formatting toolbar thanks to some code donated to me. however there was also some code to get rid of the toolbar button when the add-in was deselected and it does not work properly. can someone help me debug this and help me get rid of this button when the add-in is closed. thank you. Dim sMenu As String Private Sub Workbook_BeforeClose(Cancel As Boolean) sMenu = "myButton" On Error Resume Next Application.CommandBars("Formatting").Controls("Ma rginCalculator").Delete On Error GoTo 0 End Sub Private Sub Workbook_Open() Dim oCB As CommandBar Dim oCtl As CommandBarControl Dim newMenu As Object 'CommandBarControl Dim ctrlButton As Object 'CommandBarControl sMenu = "Margin Calculator" On Error Resume Next Application.CommandBars("Formatting").Controls(sMe nu).Delete On Error GoTo 0 Set oCB = Application.CommandBars("Formatting") Set oCtl = oCB.Controls.Add(Type:=msoControlButton, temporary:=True) With oCtl .BeginGroup = True .FaceId = 652 .Style = msoButtonIconAndCaption .OnAction = "ShowCalculator" 'SHOWS USERFORM ASSOCIATED WITH ADD-IN End With SetEnterDefault 'CODE TO MAKE A CERTAIN BUTTON DEFAULT=TRUE End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Spencer,
In the create code you delete a control called 'Margin Calculator', but in the BeforeClose code you try to delete 'MarginCalculator', no space. Also, where does the control get assigned a name? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Spencer Hutton" wrote in message ... I have an add-in. when it is selected from the add-ins list, a toolbar button shows up on the formatting toolbar thanks to some code donated to me. however there was also some code to get rid of the toolbar button when the add-in was deselected and it does not work properly. can someone help me debug this and help me get rid of this button when the add-in is closed. thank you. Dim sMenu As String Private Sub Workbook_BeforeClose(Cancel As Boolean) sMenu = "myButton" On Error Resume Next Application.CommandBars("Formatting").Controls("Ma rginCalculator").Delete On Error GoTo 0 End Sub Private Sub Workbook_Open() Dim oCB As CommandBar Dim oCtl As CommandBarControl Dim newMenu As Object 'CommandBarControl Dim ctrlButton As Object 'CommandBarControl sMenu = "Margin Calculator" On Error Resume Next Application.CommandBars("Formatting").Controls(sMe nu).Delete On Error GoTo 0 Set oCB = Application.CommandBars("Formatting") Set oCtl = oCB.Controls.Add(Type:=msoControlButton, temporary:=True) With oCtl .BeginGroup = True .FaceId = 652 .Style = msoButtonIconAndCaption .OnAction = "ShowCalculator" 'SHOWS USERFORM ASSOCIATED WITH ADD-IN End With SetEnterDefault 'CODE TO MAKE A CERTAIN BUTTON DEFAULT=TRUE End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
toolbar button | Excel Discussion (Misc queries) | |||
Toolbar button | Excel Discussion (Misc queries) | |||
New button on toolbar | Excel Worksheet Functions | |||
Delete a custom button by holding down the ALT key and dragging the button off the toolbar | Excel Programming | |||
Toolbar Button | Excel Programming |