Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
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
2003 - 2007 custom macro and custom button restore. Scott Sornberger Excel Discussion (Misc queries) 11 May 23rd 08 02:41 PM
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. Daniel Excel Worksheet Functions 1 July 12th 05 01:30 AM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
How can I make a custom button in one Excel form to e-mail easily. Katydid Excel Programming 2 February 3rd 05 06:45 PM
Can I make a custom button in Excel for the Group feature? Lisa Excel Worksheet Functions 1 December 20th 04 09:34 PM


All times are GMT +1. The time now is 03:18 PM.

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

About Us

"It's about Microsoft Excel"