Kamis, 03 Januari 2013

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.nz" railroads@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]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
Recent Activity:
----------------------------------
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