Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a button appear when the custom Add-in is selected?
Hi, I've created an Add-in by writing VBA code in an Excel XP workbook and
then saving it as and .xla file. This is my first time creating an Add-in and I see my Add-in in the Tools - Add-Ins menu so that's exciting :) Now I'd like to add a button to the Tool bar and have that button appear whenever myAddIn is enabled. And then I'd like my code (which is in my Add-in) to run when the user clicks this new button. Could someone help please? I see few similar questions here but not one that would tell me exaclty how to do that. Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a button appear when the custom Add-in is selected?
have a look at this site:
http://www.jkp-ads.com/articles/DistributeMacro00.asp -- jb "Anya" wrote: Hi, I've created an Add-in by writing VBA code in an Excel XP workbook and then saving it as and .xla file. This is my first time creating an Add-in and I see my Add-in in the Tools - Add-Ins menu so that's exciting :) Now I'd like to add a button to the Tool bar and have that button appear whenever myAddIn is enabled. And then I'd like my code (which is in my Add-in) to run when the user clicks this new button. Could someone help please? I see few similar questions here but not one that would tell me exaclty how to do that. Thank you. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a button appear when the custom Add-in is select
Thank you. I also just saw an answer by Ron de Bruin which seems to have
exactly what I need at this page http://www.contextures.com/xlToolbar02.html "john" wrote: have a look at this site: http://www.jkp-ads.com/articles/DistributeMacro00.asp -- jb "Anya" wrote: Hi, I've created an Add-in by writing VBA code in an Excel XP workbook and then saving it as and .xla file. This is my first time creating an Add-in and I see my Add-in in the Tools - Add-Ins menu so that's exciting :) Now I'd like to add a button to the Tool bar and have that button appear whenever myAddIn is enabled. And then I'd like my code (which is in my Add-in) to run when the user clicks this new button. Could someone help please? I see few similar questions here but not one that would tell me exaclty how to do that. Thank you. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a button appear when the custom Add-in is selected?
Put the following code in the ThisWorkbook module of your XLA project.
It creates a button on the Standard command bar with a caption of "Click Me". Option Explicit Private WithEvents MyButton As Office.CommandBarButton Private Const C_TAG = "MyAddInName" Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, _ CancelDefault As Boolean) MsgBox "Hello World" End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim C As Office.CommandBarControl On Error Resume Next For Each C In Application.CommandBars.FindControls(Tag:=C_TAG) C.Delete Next C End Sub Private Sub Workbook_Open() Dim C As Office.CommandBarControl ' clean up first On Error Resume Next For Each C In Application.CommandBars.FindControls(Tag:=C_TAG) C.Delete Next C On Error GoTo 0 Set MyButton = Application.CommandBars(3).Controls.Add(Type:=msoC ontrolButton, temporary:=True) ' create a new item on the Standard command bar, id = 9. With MyButton .Style = msoButtonIconAndCaption .Caption = "Click Me" .Tag = C_TAG End With End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Wed, 13 May 2009 12:06:19 -0700, Anya wrote: Hi, I've created an Add-in by writing VBA code in an Excel XP workbook and then saving it as and .xla file. This is my first time creating an Add-in and I see my Add-in in the Tools - Add-Ins menu so that's exciting :) Now I'd like to add a button to the Tool bar and have that button appear whenever myAddIn is enabled. And then I'd like my code (which is in my Add-in) to run when the user clicks this new button. Could someone help please? I see few similar questions here but not one that would tell me exaclty how to do that. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2003 - 2007 custom macro and custom button restore. | Excel Discussion (Misc queries) | |||
how do i make it so that when a sheat is selected either via link or tab, that xlLastCell is selected. the last on the sheet. | Excel Worksheet Functions | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
How can I make a custom button in one Excel form to e-mail easily. | Excel Programming | |||
Can I make a custom button in Excel for the Group feature? | Excel Worksheet Functions |