Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Custom buton for macro in an Addin file.

Hi All

I have created a Addin file (Helper.xla)with a macro called SumData in
it. I want to have this macro linked to a button on the menu bar. I
need to send this addin to various users and they should be able to use
the macro by pressing this custom button once they have added the
helper.xla.

Can you give me some code that I can add to the addin file for serving
the above purpose.

Thanks
Karthik Bhat
Bangalore

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Custom buton for macro in an Addin file.

Hi Karthik,

Here is a simple example that adds it to the Tools menu

Option Explicit

Private Sub Workbook_Open()
Dim oCb As CommandBar
Dim oCtl As CommandBarPopup
Dim oCtlBtn As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls("Tools").Controls.Add( _
Type:=msoControlPopup, _
temporary:=True)
oCtl.Caption = "myButton"
With oCtl
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtlBtn.Caption = "myMacroButton"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro"
End With
'etc.
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCb As CommandBar

Set oCb = Application.CommandBars("Worksheet Menu Bar")
oCb.Controls("Tools").Controls("myButton").Delete
End Sub


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Karthik Bhat - Bangalore" wrote in message
oups.com...
Hi All

I have created a Addin file (Helper.xla)with a macro called SumData in
it. I want to have this macro linked to a button on the menu bar. I
need to send this addin to various users and they should be able to use
the macro by pressing this custom button once they have added the
helper.xla.

Can you give me some code that I can add to the addin file for serving
the above purpose.

Thanks
Karthik Bhat
Bangalore



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
custom addin gives #name? errors bh1 Excel Worksheet Functions 4 February 5th 08 06:46 PM
An AddIn for a custom function FARAZ QURESHI Excel Discussion (Misc queries) 3 October 16th 07 02:35 PM
How I know if a file is using a custom addin Rodrigo Ferreira Excel Discussion (Misc queries) 3 September 15th 06 02:44 PM
How I know if a file is using a custom addin Rodrigo Ferreira Excel Worksheet Functions 1 September 15th 06 02:08 AM
Create button with addin/reference macro in another file netzig Excel Programming 2 February 6th 04 10:36 PM


All times are GMT +1. The time now is 11:28 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"