+ Reply to Thread
Results 1 to 9 of 9

ToggleBar changes colors

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    ToggleBar changes colors

    I'm trying to use a toggle bar to run one of two macros. Everything's working correctly, except for the fact that the format of the toggle bar changes depending on which way it's toggled. I've set it to have a solid Black background, with Red font. It looks like that until you click on it, at which time the background changes to what looks like a grey hatched background. The red font is still there, but very hard to read against the grey hatch. Is there a way to stop the color changing?

    Or, is there a better option than a toggle? Basically, I either want the toolbars to show or not to show. The default is "No Show", you have to click to show, but frequently the user is going to want to switch back and forth. I have limited space so would like to use one toggle button instead of 2 command buttons.
    Last edited by jomili; 02-22-2011 at 11:29 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: ToggleBar changes colors

    Hello Jon,

    What you are describing is normal for a Toggle control. You could use a CommandButton and change the caption to indicate the function "Show Toolbars" or "Hide Toolbars".
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: ToggleBar changes colors

    Leith,

    If I did it as a command bar, wouldn't I need two of them, one to turn off, one to turn back on? That's what I'm trying to avoid due to space constraints.

    If the behaviour is consistent for toolbars, do you know of another color combination (other than Red and Black) which is readable both ways?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: ToggleBar changes colors

    Hello John,

    You can use one CommandButton to both. Your code can check the state of the toolbars (visible or not) , perform the opposite action and change the caption accordingly.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: ToggleBar changes colors

    Okay, I'm with you conceptually, but how do I check to see if the toolbars are visible or not? Is it something like:
    Please Login or Register  to view this content.


    Also, BTW, I'm using code you originally gave me in this thread (http://www.excelforum.com/excel-prog...-headings.html). Recently my workbook quit hiding the Windows Taskbar when going full-screen.
    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: ToggleBar changes colors

    Hello John,

    As an example, let's use the "Worksheet Menu Bar". Set the caption of the CommandButton initally to "Hide Toolbars".
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: ToggleBar changes colors

    Whoa! I guess I did something wrong!

    I opened Excel, created a command bar titled "Hide Toolbars" on Sheet 1, pasted in your code, it the bar to trigger the code, and Excel cussed at me!

    Well, not really cussing, but I've never before seen this error code:
    Please Login or Register  to view this content.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: ToggleBar changes colors

    Hello John,

    Sorry, I forgot the "Worksheet Menu Bar" is a special case. You have to use the Enable property. Here is the corrected code...
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: ToggleBar changes colors

    Okay, I think I've got it, other than some fine tuning.

    For my purposes, the second bit of code I posted (from the older thread) is the equivalent of the
    Please Login or Register  to view this content.
    " line in your code. So, could I replace the "enabled=True" line with
    Please Login or Register  to view this content.
    and the "enabled = False" line with
    Please Login or Register  to view this content.
    Would it better to use the Run command, or replicate the macros in the ClickButton macro? Or am I missing the point entirely?

+ 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