Derek,
Yes, Excel 2007 and 2010 create toolbars in "Add-ins"..
To remove them, you use:
Application.CommandBars("MyToolbarName").Delete
Paul
-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------
________________________________
From: Derek Turner g4swy@yahoo.com>
To: "ExcelVBA@yahoogroups.com" ExcelVBA@yahoogroups.com>
Sent: Thu, January 3, 2013 12:36:39 PM
Subject: Re: [ExcelVBA] Floating Toolbar
Dear All, Dear Charlie
Charlie did not say what Excel version he has, but when I ran this code in Excel
2010 it created a new item called 'Add-Ins' in the menu bar which contains the
AAA and BBB items.
Unfortunately the RemoveMenubar code does not work and I am stuck with this
until I find out how to do it myself in my version, presumably by tampering with
the registry.
Derek Turner
+++
>________________________________
> From: "railroads@slingshot.co.nzrailroads@slingshot.co.nz>
>To: ExcelVBA@yahoogroups.com
>Sent: Thursday, 3 January 2013, 1:44
>Subject: [ExcelVBA] Floating Toolbar
>
>
>
>
>HI
>
>Courtesy of Contextures I am using the code below for a floating toolbar. Works
>well. However I would like to be able to have the toolbar appear on the same as
>the menu row. With File,Edit,View. etc.
>When I drag it up it will only go on its own row above or below the menu row. Is
>it possible to attach somehow ?
>Can the new toolbar be made to work as a dropdown. That is when you click on the
>name a drop down of the items appears and you select item required.
>
>Thankyou
>
>Charlie Harris
>
>*******************
>Option Explicit
>
>Public Const ToolBarName As String = "MyToolbarName"
>'===========================================
>Sub Auto_Open()
>Call CreateMenubar
>End Sub
>
>'===========================================
>Sub Auto_Close()
>Call RemoveMenubar
>End Sub
>
>'===========================================
>Sub RemoveMenubar()
>On Error Resume Next
>Application.CommandBars(ToolBarName).Delete
>On Error GoTo 0
>End Sub
>
>'===========================================
>Sub CreateMenubar()
>
>Dim iCtr As Long
>
>Dim MacNames As Variant
>Dim CapNamess As Variant
>Dim TipText As Variant
>
>Call RemoveMenubar
>
>MacNames = Array("aaa", _
>"bbb")
>
>CapNamess = Array("AAA Caption", _
>"BBB Caption")
>
>TipText = Array("AAA tip", _
>"BBB tip")
>
>With Application.CommandBars.Add
>.Name = ToolBarName
>.Left = 200
>.Top = 200
>.Protection = msoBarNoProtection
>.Visible = True
>.Position = msoBarFloating
>
>For iCtr = LBound(MacNames) To UBound(MacNames)
>With .Controls.Add(Type:=msoControlButton)
>.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
>.Caption = CapNamess(iCtr)
>.Style = msoButtonIconAndCaption
>.FaceId = 71 + iCtr
>.TooltipText = TipText(iCtr)
>End With
>Next iCtr
>End With
>End Sub
>
>'===========================================
>Sub AAA()
>MsgBox "aaa"
>End Sub
>
>'===========================================
>Sub BBB()
>MsgBox "bbb"
>End Sub
>
>*************************
>
>
>
>
>
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (4) |
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar