+ Reply to Thread
Results 1 to 11 of 11

UserForm Colour Themes

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Talking UserForm Colour Themes

    I don't usually set any colours on the forms I create so they end up looking drab and unimaginative. I decided lets create preset colour themes that could be automatically applied to any form. You could then call one of these presets in the Form Initialize event. Job Done.

    Why stop there? You could place a button on the form so that if the end user didn't like the colours in your default choice of theme, they could change the forms theme at run-time.


    Attached is where I'm up to.


    I'm looking for some help on any of the following:
    • I need some more colour themes! So let your imagination run wild! I don't mind how "loud" the theme is that you suggest - the only requirement is a good set of contrast so that the fore-color is easy to read against the back-colour (so no pale green on pale yellow background!) A theme name for each colour theme provided would be nice but is not essential.
    • I need some technical help #1 - It auto applies the colour based on the control name prefix. Not all coders use naming conventions so ideally the Select Case should use the Controls Type instead to be more reliable. But how?! (UPDATE: This has been solved by millz)
    • I need some technical help #2 - The color theme doesn't work well for all controls so appreciate code to fix any of these
    Attached Files Attached Files
    Last edited by mc84excel; 08-28-2014 at 02:19 AM. Reason: update solved
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: UserForm Colour Themes

    This looks really interesting, thanks for coming up with this. May implement this idea in the future if I ever get the chance
    • I changed the select case code to look at TypeName instead of the control name. I also added TypeName textbox to the colouring.
    • For pages, I used a frame to act as the background so it gets coloured just like the background, then you can add controls on top of it (only did for Page 1).
    • I added 2 themes and named them Brinjal and Bumblebee, lol.
    Attached Files Attached Files
    多么想要告诉你 我好喜欢你

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    Nice work millz! I like what you've done. +1

    Quote Originally Posted by millz View Post
    I changed the select case code to look at TypeName instead of the control name.
    Thanks! It's easy when you know how!
    I wanted this working so that any coders wanting to add this module to any of their projects wouldn't be forced to use naming conventions for their form controls. In other words, all anyone should need to do is import the bas, add a call in the form initialize event and voila.

    Quote Originally Posted by millz View Post
    I also added TypeName textbox to the colouring.
    I had deliberately omitted textbox from the theme colouring because I am worried that some end users may not notice it's a textbox at first glance. So I may end up reversing that change.

    Quote Originally Posted by millz View Post
    For pages, I used a frame to act as the background so it gets coloured just like the background, then you can add controls on top of it
    Interesting work-around.

    I guess the other alternative would be to leave the multi pages 'un-themed' (like the textbox controls). That way the module would work 'out-of-the-box' - it wouldn't require any changes to the existing forms controls. The downside to leaving the multipage pages un-themed is that themed controls on these pages just won't look right.

    Quote Originally Posted by millz View Post
    I added 2 themes and named them Brinjal and Bumblebee, lol.

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    Solved this question
    Last edited by mc84excel; 08-31-2014 at 08:04 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    v3 attached
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    v4 attached.
    • Added border colors (so maybe I should call it a 6 colour theme? lol - but for now I've only set border colors same as the forecolors)
    • Added line of code in UserForm_Initialize to demonstrate how the form could be set to a random theme on each open
    • Stopped applying theme to ScrollBar (Decided to keep consistent with the unthemed ScrollBar that appears inside a listbox)
    • From above - since we are not theming ScrollBars anymore, I decided to stop theming the SpinButtons as well.


    Current problem I'm having is keeping a listbox selection highlighted when I change the listbox colors. I will open a separate thread for this issue. UPDATE: This was solved by millz
    Attached Files Attached Files
    Last edited by mc84excel; 09-02-2014 at 10:51 PM. Reason: update

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    v5 attached
    • Added millz fix for listbox selection
    • Added 4 more themes


    What if the user wanted to have the form reset to use default themes? I've tried adding this (you need to call the sub using theme arg #255) but only realised afterwards that VBA doesn't use a 4 (or 6 - see my previous post) colour theme. The listbox and combobox etc. use different default colors.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    08-14-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    135

    Re: UserForm Colour Themes

    These are really cool Gives me something to figure out and try and add to my userforms. Certainly gives them more personality

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    I have had to put this on hold for now but I intend to come back and finish it off.

    I feel I've started to over-complicate it so I've been rethinking the number of colours used and how they are applied.

  10. #10
    Forum Contributor
    Join Date
    08-14-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    135

    Re: UserForm Colour Themes

    If you ever want some more colors this page the codes all seemed to work when I tried them so no having to use hex2dec to find new colors
    http://cloford.com/resources/colours/namedcol.htm

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm Colour Themes

    Quote Originally Posted by mc84excel View Post
    I have had to put this on hold for now but I intend to come back and finish it off.

    I feel I've started to over-complicate it so I've been rethinking the number of colours used and how they are applied.
    The other projects I am working on are taking up a lot of time. So until I can properly resume this project, below is the latest beta if anyone is interested.

    A word of warning:
    If you have any ListBox event macros, they WILL be triggered by the color change.
    If you need to avoid this, you can - by adding a module level boolean to the form e.g.

    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Last edited by mc84excel; 12-11-2014 at 05:53 PM.

+ 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. Windows 2000 Themes
    By Lennnny in forum Microsoft Windows Help
    Replies: 2
    Last Post: 05-09-2014, 06:39 PM
  2. Use different color themes in the same document
    By Mdi3 in forum Word Formatting & General
    Replies: 2
    Last Post: 11-22-2011, 06:53 AM
  3. Colour Themes in Excel 2007
    By Blake 7 in forum Excel General
    Replies: 1
    Last Post: 10-12-2010, 05:06 AM
  4. Excel 2007 : Color Themes don't apply
    By thunter5 in forum Excel General
    Replies: 2
    Last Post: 09-25-2010, 01:23 AM
  5. Userform / Visual Themes Clash
    By jonzo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2006, 07:29 AM

Tags for this Thread

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