create Add-ins toolbar

  • Thread starter Thread starter shital
  • Start date Start date
S

shital

hi,
i have created Add-ins what i want is i want to create
toolbar for that add-ins.
When i add add-ins into my home excel toobar have to come
Automatically.
or when i add add-ins into others computer toolbar should
come Automatically

Thanks

Shital shah
 
The following is taken staright from a file I have set up. You will have
to amend it as tou need for you file.

Duncan



Public Sub OnLoad()

Dim WSBar As CommandBar
Dim ihelpindex As Integer
Dim UtilityMenu As CommandBarControl
Dim i

Set WSBar = CommandBars("Worksheet Menu Bar")
ihelpindex = WSBar.Controls("Help").Index
Set UtilityMenu = WSBar.Controls.Add(Type:=msoControlPopup,
Temporary:=True, before:=ihelpindex)

Line1:

For i = 1 To WSBar.Controls.Count 'When loaded on multiple
occasions without closing xl, toolbar does not reset.
If WSBar.Controls(i).Caption = "&Utilities" Then
WSBar.Controls(i).Delete (True): GoTo Line1
Next

With UtilityMenu
..Caption = ("&Utilities")
With .Controls.Add(Type:=msoControlButton)
..Caption = "Remove Duplicates"
..OnAction = "showfrm"
End With
End With

fmSplash.Show

End Sub
 
Hi Norman
the web site is not opening. any other web site or new name
thanks

Shital
 
Hi Shital,
Hi Norman
the web site is not opening. any other web site or new name
thanks

Shital


The URL works for me!
However, here is a copy of JKP's post:

Hi Phill,
Does anyone know how to create a toolbar that will run
some code in an .xla? I want this toolbar to be
displayed when the add-in is loaded (checked) and go away
when the add-in is unloaded (unchecked).

Excel keeps toolbar and menubar customizations in a file with the
extension .xlb. The exact filename depends on Excel version and
install, but usually is: Excel9.xlb or Excel.xlb or Username8.xlb.
Often this file can be found in your WINDOWS directory.

You can attach a toolbar to a workbook. When this workbook is loaded,
XL checks if the toolbar is on the system. If not, it copies the
toolbar from the workbook to the system.

After creating *or changing* the toolbar, you should attach the toolbar
to your workbook:

- activate the workbook to which you want to attach the toolbar
- Rightclick the toolbar, select 'customize'
- Click 'Attach' (Toolbars Tab)
- If the workbook already contains a toolbar by that name, delete it
first by clicking on it on the righthand side and choosing Delete.
- Select your toolbar (on the left) and press 'copy'
- Save the workbook (optionally: save_as an add-in).

Also, you should include code that deletes the toolbar when your
workbook or add-in is closed, so that when you deliver a new version of
your workbook the new toolbar will be used i.s.o the old one. You can
do that in the Thisworkbook module, using the Workbook_BeforeClose
event:

Private Sub Workbook_BeforeClose(Cancel as Boolean)
On Error Resume Next 'In case Toolbar is absent
Application.CommandBars("YourBarsName").Delete
End Sub

After that you save the workbook as filetype Add-in and you're done.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top