+ Reply to Thread
Results 1 to 3 of 3

Command Bars

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-06-2008
    Location
    Manchester
    MS-Off Ver
    MS Office 2003
    Posts
    161

    Command Bars

    I have create a Command Bar, my problem I'm trying to understand is this

    1.Can you amend the font colour of the any Captions on the CommandBar?
    2.How can I get the Caption to pick up from a range and use the range name as the Caption?

    I have named a range in a worksheet that I want to pick up and use as the range

    Below is my CommandBar code

    Sub ComBar()
    Dim cmdBar As CommandBar
    Dim cmdPopup As CommandBarPopup
    Dim cmdButton As CommandBarButton
        DeleteComBar
        Set cmdBar = CommandBars.Add(Name:="Tracker", _
        Position:=msoBarFloating, Temporary:=True)
        With cmdBar
            .Top = 150
            .Left = 50
    
        Set cmdPopup = .Controls.Add(Type:=msoControlPopup)
        With cmdPopup
            .Caption = " Last View "
            .BeginGroup = True
            Set cmdButton = .Controls.Add(Type:=msoControlButton)
            With cmdButton
                .Caption = Range("LastSheetViewed").Select
                .Style = msoButtonCaption
                .BeginGroup = True
    'I will use the range to build code to select which sheet the report will go to
                .OnAction = "LastView"
            End With
        
        Set cmdButton = .Controls.Add(Type:=msoControlButton)
            With cmdButton
                .Caption = " Home "
                .Style = msoButtonCaption
                ''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
                .BeginGroup = True
                .OnAction = "GoToHome"
        End With
        
        Set cmdButton = .Controls.Add(Type:=msoControlButton)
            With cmdButton
                .Caption = " Download Tracker "
                .Style = msoButtonCaption
                .BeginGroup = True
                .OnAction = "Download"
        End With
        
        .Width = 1000
        .Visible = True
    End With
        
    End Sub
    
    Sub DeleteComBar()
    On Error Resume Next
    CommandBars("Tracker").Delete
    On Error GoTo 0
    End Sub
    Last edited by JezLisle; 03-02-2010 at 11:16 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Command Bars

    No changing font colours. They set by Windows settings.

    You can reference the range and apply the value using something like,

    .Caption = Range("MYname").value    ' " Last View "
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    06-06-2008
    Location
    Manchester
    MS-Off Ver
    MS Office 2003
    Posts
    161

    Re: Command Bars

    Excellent thanks for this :-) works great

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1