+ Reply to Thread
Results 1 to 8 of 8

How-to: Toggle the button face on a custom toolbar?

  1. #1
    Registered User
    Join Date
    10-26-2004
    Location
    Portland, Oregon
    MS-Off Ver
    Excel in Windows
    Posts
    49

    Post SOLVED: How-to: Toggle the button face on a custom toolbar?

    I have a custom toolbar that works fine. One of the buttons is a toggle: Click it and columns are hidden, click it again and the columns are unhidden -- very simple and it works. I would like to change the button face in response. So when the toolbar is first created it has a default button face. Clicking the button will run the macro and change the button face. Click the button again and the macro runs again and changes the button face back.

    TIA!
    Last edited by Air_Cooled_Nut; 01-29-2008 at 02:29 PM. Reason: I figured out how to do it.
    ~Toby

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523
    Quote Originally Posted by Air_Cooled_Nut
    I have a custom toolbar that works fine. One of the buttons is a toggle: Click it and columns are hidden, click it again and the columns are unhidden -- very simple and it works. I would like to change the button face in response. So when the toolbar is first created it has a default button face. Clicking the button will run the macro and change the button face. Click the button again and the macro runs again and changes the button face back.

    TIA!
    I am not sure if this will work in your situation, but take a look anyway, you might get an idea:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-26-2004
    Location
    Portland, Oregon
    MS-Off Ver
    Excel in Windows
    Posts
    49
    No, it's not the Caption that I want to change, I want the actual button face to change.

    However, thanks for mentioning that! That is a great idea to change the tooltip (mouse hover?) I can put that into my code.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening Air_Cooled_Nut

    Without seeing the code you've got so far it's hard to relate this directly to your case, but you need to be exploring the State properties of the relevent control, the property in question needs to be set to msoButtonUp or msoButtonDown, thus :

    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  5. #5
    Registered User
    Join Date
    10-26-2004
    Location
    Portland, Oregon
    MS-Off Ver
    Excel in Windows
    Posts
    49
    Create the toolbar:
    Please Login or Register  to view this content.
    The subroutine used by the toolbar button and where the SPECIFIC toolbar button would be changed:
    Please Login or Register  to view this content.
    Also, is there are way to give each toolbar button an identification or are they automatically assigned an index number (Item() )? Maybe this would make it easier? I don't know.

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening Air_Cooled_Nut

    Something like this seems to work OK :

    Please Login or Register  to view this content.
    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    10-26-2004
    Location
    Portland, Oregon
    MS-Off Ver
    Excel in Windows
    Posts
    49
    No, the actual image of the button face will change to a different image after the click macro has occured and it will remain so until the button is clicked again. I'm not concerned with changing the look of the button during the click.

    From the VBA Help in Excel:
    FaceId Property
    Returns or sets the Id number for the face of a command bar button control. Read/write Long.

    Remarks
    The FaceId property dictates the look, not the function, of a command bar button. The Id property of the CommandBarControl object determines the function of the button.

  8. #8
    Registered User
    Join Date
    10-26-2004
    Location
    Portland, Oregon
    MS-Off Ver
    Excel in Windows
    Posts
    49
    Ha! Using the example code given in the VBA Help for .FaceID, I was able to figure it out. The below code works:

    Please Login or Register  to view this content.

+ 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