LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default add a toolbar button for an add-in

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
toolbar button Dennis S. Excel Discussion (Misc queries) 5 July 9th 08 03:52 AM
Toolbar button fda secretary Excel Discussion (Misc queries) 1 October 22nd 07 09:41 PM
New button on toolbar attaboy Excel Worksheet Functions 5 January 23rd 07 04:17 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
Toolbar Button Gary Chan Excel Programming 4 August 21st 03 09:20 PM


All times are GMT +1. The time now is 08:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"