Addins

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

My Personal.XLS module contains code that is attached to a
custom button I created on my menu toolbar. That button
is now on every workbook I have open, and because the code
is attached to it, it can be run on any workbook I have
open.

I need to install this code thats in my personal.xls in
everyone elses personal.xls, but Bob Phillips made the
suggestion to just create an addin so I wont destroy other
peoples code that may be in their personal.xls.

Because of this, I am going to create an addin which
contains the same code that is in my Personal.XLS. The
only problem is how will I get that button on everyone
elses computer without me having to manually create/load
it on their computers. I want the code to be attached to
the button.

Thank you

Todd Huttenstine
 
Todd,

The way that I would do it is to create the button from within the addin
code. The following code creates a simple commandbar with a button which you
can customise. Just put a call to this proc in the Workbook_Open event in
THisWorkbook.

Public Sub CreateCommandBar()
Dim oCB As CommandBar
Dim objButton As CommandBarButton

On Error Resume Next 'just in case
Application.CommandBars("Todd's toolbar").Delete

On Error GoTo 0

With Application
Set oCB = .CommandBars.Add("Todd's toolbar", msoBarTop, , True)
With oCB

Set objButton = .Controls.Add(msoControlButton, , , , True)
With objButton
.Caption = "Test Toolbar"
.Tag = "Personal button"
.TooltipText = "An example of tooltip text"
.Style = msoButtonIconAndCaption
.OnAction = "Todd's macro"

End With

End With

oCB.Visible = True

End With

End Sub


If you intend to add lots of buttons, it is probably best to create a table
driven commandbar builder. I have a simple example if you want it.

By the way, you can add icons to the button s. John Walkenbach has a nice
utility to help you pick the id at
http://j-walk.com/ss/excel/tips/tip67.htm
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top