+ Reply to Thread
Results 1 to 17 of 17

Hide Show Excel Toolbars using a Toggle Button

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Hide Show Excel Toolbars using a Toggle Button

    I currently have two macros, one to remove the excel toolbars, another to show them.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    The toolbars are removed for this workbook when the workbook is opened and they are restored when the workbook is closed by using the following Workbook Activate code placed in 'This Workbook'

    Please Login or Register  to view this content.
    How can I convert this into a toggle 'shape' button, so that it allows the user to toggle between all toolbars hidden and all toolbars shown with the button text changing between 'Hidden' and 'Shown' accordingly.

    Also, is there a way to be selective as to which toolbars are hidden and shown? For example if I want all the toolbars to be hidden apart from the status bar or all apart from the formula bar etc, how would I do this?

    Many thanks

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    Then try the following

    Place a commandbutton on the sheet and insert this code into the sheets codemodule

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    Hi Steffan,

    Many thanks. I'm using a shape (Insert/Shape), so I adapted this slightly to

    Please Login or Register  to view this content.
    How would I add to this code to toggle the text displayed on the button between 'Show' and 'Hide', bearing in mind it is a shape rather than a command button?

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    Then you could do it like this

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    Steffan,

    Many thanks, that works perfectly...

  6. #6
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    Hi Steffan,

    How could I expand on this. I'd like to hide all the toolbars when the sheet opens, kepping the option to toggle them all on or off, but using additional shape toggle button, allow the user to show/hide individual toolbars, e.g. the status bar or the ribbon or the formula bar etc.

    I tried this, but it doesn't work.

    Please Login or Register  to view this content.
    Many thanks...

  7. #7
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    If you need to hide the ribbon when the sheet open,

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    Okay, three questions...

    Question 1
    I placed this code in 'This Worksheet', is this the correct place for it and is this correct to restore all the toolbars on exiting the workbook?

    Question 2
    How do I stop any other workbook opened at the same time as this one from having the toolbars hidden. I would need this to be specific to this workbook only.

    Please Login or Register  to view this content.

    Question 3
    I can create a button using this code to then toggle the 'Staus Bar' on and off:

    Please Login or Register  to view this content.
    or the Formula bar on and off:

    Please Login or Register  to view this content.
    or the Tabs on and off:

    Please Login or Register  to view this content.
    But how would I create a second button to toggle the 'Ribbon' on and off, as this doesn't work?

    Please Login or Register  to view this content.
    I'm new to VBA, so I need some hand holding in terms of where the code needs to go etc.

    Many thanks...

  9. #9
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    1.

    Yes

    2.

    Yes.

    Create a check on the workbbok name

    Please Login or Register  to view this content.
    3.

    Not sure, but try this

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    So, changing the code to this:

    Please Login or Register  to view this content.
    where Test 1.xlsm is the name of the workbook, doesn't stop any other workbooks opened whilst Test 1.xlsm is open from having it's toolbars hidden. What am I doing wrong?

    Like I said, I am new to VBA, so I'm not sure when I'm putting code in the wrong place...

    Many thanks

  11. #11
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    It seems for the Ribbon, if it is shown when the sheet is opened, your code will hide it on the first button click but it won't re show it as a toggle and vice versa, if the ribbon is hidden when the worksheet is opened, the first button click will show it, but again it doesn't toggle?

  12. #12
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    Ahh,

    ok, it couldnt test like this.

    Put this in the top off a module outside any sub

    Please Login or Register  to view this content.
    Then in thw workbook_open event where you hide the ribbon insert this

    Please Login or Register  to view this content.
    Then you can use this logic in the toggle event of the ribbon

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    Hi Steffan,

    That fixes the toggle button, which now correctly toggles the ribbon on and off, however, I still have the issue where, if the ribbon or any of the toolbars are hidden, they are also hidden when I open any other workbooks. I tried your suggestion of creating a check on the workbbok name, but this doesn't seem to work for me.

    Am I doing something wrong?

    Please Login or Register  to view this content.

  14. #14
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    Then try this

    Please Login or Register  to view this content.
    This fires when you leave focus from the workbook.

    Then you need a similar event when it gets focus again.

  15. #15
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    So, I tried this which still doesn't work, are you able to amend the sample attached rather than us going back and forward as I'm clearly missing something!

    Please Login or Register  to view this content.
    Many thanks
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Hide Show Excel Toolbars using a Toggle Button

    It work at my end,

    When i press the button it hides the ribbon, if i then open another workbook, the other workbook has the ribbon showed, no matter what i do in the first.
    Isn't this how it's supposed to act?

  17. #17
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Show Excel Toolbars using a Toggle Button

    Hi Steffan,

    A slight hiccup. Having this code on the 'ThisWorkbook' means that as soon as I switch to any other tab in the same Workbook, I lose the ribbon and formula bar etc.

    Please Login or Register  to view this content.
    Would I simply remove the code from 'ThisWorkbook' and apply it to just the 'Worksheet' I want the changes to affect and if so, how should I tweak the code?

    Also, if I were to do this, I assume the toolbars wouldn't be reset on exting the Workbook, is that correct? How would I overcome that problem?

+ 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