+ Reply to Thread
Results 1 to 8 of 8

Reset CustomUI Toggle Button state by cancelling Input Prompt

  1. #1
    Registered User
    Join Date
    11-21-2015
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 2013
    Posts
    52

    Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi All,

    My workbook has a CustomUI toggle button that toggles between setting a scroll-area by specific range to no scroll area restriction. By default the scroll area is set. The user is prompted for a password to unset the scroll area. My code works fine in setting and unsetting the scroll area however if the user cancels out of the password InputBox the Toggle Button control still shows the 'pressed' state and the incorrect 'label'. I can't figure out how to change the toggle button control to show the correct state and label.

    The attached workbook is an example of what I am trying to achieve

    ToggleButtonTest.xlsm

    Any help appreciated

    Rick

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi there,

    Take a look at the attached workbook and see if it does what you need.

    It uses the following code:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-21-2015
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 2013
    Posts
    52

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi Greg

    Thanks for response. Not quite there. The label returns to its un-pressed state when the InputBox is cancelled, however the pressed state of the toggle button displays incorrectly. It shows pressed whilst the InputBox is displayed and does not return to the unpressed state when the InputBox is cancelled

    Regards
    Rick

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi again,

    Sorry, I misunderstood part of your original post.

    The following code in the attached workbook should do what you need. It includes error handling to provide a "graceful exit" in the situation where the reference to the Ribbon is no longer available.

    Please Login or Register  to view this content.

    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files
    Last edited by Greg M; 02-10-2016 at 07:25 AM. Reason: Additional information

  5. #5
    Registered User
    Join Date
    11-21-2015
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 2013
    Posts
    52

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi Greg,

    Thanks again for replying. I read your post about reasons why you did not first implement the Pressed state (did you delete the post?) and it got me thinking. To be honest I had not thought about consistency in the buttons but since you mentioned it I can see logic in that. I have decided, therefore, to use a check-box instead of a toggle button. This will give the user the visual indication that the scroll area is unset. The reason I need to have this visual aid is in order for an Administrator User to remember that he/she has unset the scroll area (in order to do admin type work) and therefore not allow the worker user (workbook is shared) to access the protected areas.

    I also check the state of the scroll area when changing sheets. I did not include this in my original post as I did not think that it would affect any forthcoming answer. Wrong.

    The attached file now includes my code that changes the state of the check box depending on a true or false value in Cell A1. But the issue of cancelling out of the InputBox and reversing the checked and label states still remains.

    Apologies for mucking you around and hope you can fix this one up. I've also learnt to clean up my code by using your submitted code as an example

    Cheers
    Rick
    Attached Files Attached Files

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi again Rick,

    Ok on all of that. Yes, I deleted my original post (regarding inconsistency etc.) because I had written it as a result of misunderstanding your requirements.

    I've had a look at your latest workbook and I think the question of inconsistency arises once again, i.e. the label text associated with the CheckBox shouldn't change in response to the Checked/Unchecked state of the ComboBox. My attached version has the Checkbox displayed with an unchanging "Scroll Area Unrestricted" text, and the Checked/Unchecked state of the Checkbox reflects the True/False state of this text.

    I've tweaked the code a bit so it's no longer necessary to store the required "pressed" state of the checkbox in Cell A1 of each worksheet. I've also moved most of the code from the ThisWorkbook CodeModule to the standard CodeModule. This is just a personal preference - I try to keep as much code as possible in standard CodeModules rather than in Workbook/Worksheet CodeModules.

    Incidentally, you had "hidden" the contents of each Cell A1 by setting the font colour to be the same as the cell interior colour - a simpler way to achieve this is to use the Custom format of ";;;" (without quotes) for the Number format property of those cells.

    Anyway, take a look at the attached workbook and see what you think - it uses the following code:

    Please Login or Register  to view this content.

    Hope this helps - as always, please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-21-2015
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 2013
    Posts
    52

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Cheers Greg.

    That is exactly what I'm after. All points noted and taken on board. This has been a good learning lesson for me and I appreciate all the work and suggestions.

    Rick

  8. #8
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Reset CustomUI Toggle Button state by cancelling Input Prompt

    Hi again Rick,

    Many thanks for all of your feedback, for the Reputation increase, and for the kind words therein - much appreciated

    Very pleased that I was able to help out.

    Best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Toggle Button Does not Toggle OFF when Clicked
    By robbfamily in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-19-2014, 05:12 PM
  2. [SOLVED] Reset All Toggle Buttons
    By Ash_ in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-07-2014, 09:29 AM
  3. Replies: 1
    Last Post: 02-13-2014, 10:55 PM
  4. Need help locking 2 state toggle button
    By SJMaye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2013, 06:02 AM
  5. [SOLVED] Return Toggle Button to default state
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2012, 04:51 PM
  6. [SOLVED] Toggle Button 'State' Problem on Workbook Open
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2012, 06:35 AM
  7. Cancelling an inputbox if blank input or cancel button is pressed
    By kathhying in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2011, 12:07 PM

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