+ Reply to Thread
Results 1 to 12 of 12

Excel color-pick eye dropper

  1. #1
    Registered User
    Join Date
    02-02-2010
    Location
    playa del carmen, mexico
    MS-Off Ver
    ms office 2007
    Posts
    52

    Question Excel color-pick eye dropper

    Hi

    I am trying to create a front-page, control-panel style user form that among other things would enable the user to recolor certain aspects of the entire workbook based upon an eye-dropper tool that would pick any color from anywhere on screen (inside or outside of excel).
    Ideally, I would like it to be a simple button, click on color, and then have a square next to the selection panel that would display this color. So an add-in would be the most viable solution, however, any form of coding that works is good enough for me.

    I am currently at the stage of being able to enter a hex value into the form manually, display the color box using that hex-color in the form next to the selection panel, and upon completion of the form, edit which colors I need within the entire workbook.

    And I have an external application that will select the hex value of any pixel's color and paste it in the clipboard, so if could figure a way to run the small application upon the button-click, take the value from the clipboard, and then close the application, that would work.

    Is there any way out there to be able to achieve this color-picking selection within excel, or am i really over-stretching myself on this one?
    Last edited by globalpontoon; 02-12-2010 at 09:53 PM.

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

    Re: Excel color-pick eye dropper

    Hello globalpontoon,

    Welcome to the Forum!

    It is possible to do what you want. It is important to remember the background color of worksheet cells is set to a 56 color palette. Any hex RGB values you use will be converted to the closest matching palette color.

    The pixel portion and clipboard retrieval will require using API (Application Programming Interface) calls. This is low level code that accesses the operating system. If you are not familiar with it, you should have someone who is help you with the code.

    System color values are not the same as RGB values and have to be translated using an API call. HTML hex colors don't always render the same as the Windows RGB values. Matching these colors may not be exact.
    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
    Registered User
    Join Date
    02-02-2010
    Location
    playa del carmen, mexico
    MS-Off Ver
    ms office 2007
    Posts
    52

    Re: Excel color-pick eye dropper

    Thanks for the information Leith.

    I was aware of most of the things you mentioned regarding colors, and how to take the information from the eye-dropper and do what i want with it, it was the eye dropper part I was having the problem with, so thanks for giving me the new line to look down.

    As for using the API, you mentioned that it will access the operating system.

    Before stating my next question, I should probably clarify the purpose of this eye-dropper tool, and how i intend to use it.
    I will be basically creating a template wizard which will run from the initial user-form, creating generic yet complex sheets to be used by others in various different locations, systems, companies, and would like the wizard to be able to alter the colorings of the sheet to match those of its user/company.

    And therefore my question is thus,

    Using the API you mentioned, will this mean enclosing a copy of the eye-dropper application as part of their package, or is it going to create an internal programming system that has taken the code from the initial application and converted it into excel-usable coding.

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

    Re: Excel color-pick eye dropper

    Hello globalpontoon,

    All versions of Windows contain API calls (Dynamic Link Libraries). This is what runs the operating system. The API calls can differ from from one version of Windows to another. So, it is important to know which operating systems the program will be working with. Because this all low level code, there is no automatic selection for the call that fits the system it is running on. That is the responsibility of the programmer as is error checking.

    For what you want to do, there aren't many API calls that will need to be used and will work with Windows 98 through 2003. Vista and Windows 7 systems are quite different in their layout from the previous version. I would need to check to be sure about compatibility.

    The needed API call declarations would be in a standard VBA module which would be in the Add-In. The Add-In would need to check that the operating system supports the calls before running them. Calling APIs that don't exist can easily crash the computer.

  5. #5
    Registered User
    Join Date
    02-02-2010
    Location
    playa del carmen, mexico
    MS-Off Ver
    ms office 2007
    Posts
    52

    Re: Excel color-pick eye dropper

    OK, again, thanks Leith.

    That seems to make simple enough sense, I shall see what happens, and if i manage to create a viable working eye-dropper, shall be sure to include it here for others to use.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003, 2007, 2010 & 2013
    Posts
    18,535

    Re: Excel color-pick eye dropper

    Here is one I made a while ago.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  7. #7
    Registered User
    Join Date
    02-02-2010
    Location
    playa del carmen, mexico
    MS-Off Ver
    ms office 2007
    Posts
    52

    Re: Excel color-pick eye dropper

    Thanks Andy,

    This is great. Just needs a subtle tweak to fit the functionality I need, but apart from that, it works really well.

    Again, thanks

  8. #8
    Registered User
    Join Date
    07-28-2014
    Location
    Ogden, Utah
    MS-Off Ver
    2010
    Posts
    1

    Re: Excel color-pick eye dropper

    Very nice. Thank you for this.

  9. #9
    Registered User
    Join Date
    09-28-2016
    Location
    Madrid, Spain
    MS-Off Ver
    2007, 2010, 365
    Posts
    1

    Re: Excel color-pick eye dropper

    Are the RGB values exported somehow or should I manually copy them to the "More colors...." dialog? Also, could the code behind it be used in Visio? It supports VBA, after all.

    Thanks a lot, Andy

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003, 2007, 2010 & 2013
    Posts
    18,535

    Re: Excel color-pick eye dropper

    No export. Whilst it's possible to display the More colours dialog with loaded values they don't get applied to anything.

  11. #11
    Registered User
    Join Date
    01-12-2019
    Location
    Trkey
    MS-Off Ver
    2016
    Posts
    2

    Re: Excel color-pick eye dropper

    Quote Originally Posted by Andy Pope View Post
    Here is one I made a while ago.
    Hi,
    Compile Error for 64bit version.
    It need to update for 64bit. Could you please help?
    Thank you very much.

    Please Login or Register  to view this content.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    30,944

    Re: Excel color-pick eye dropper

    Open a thread of your own for this query. Thanks!
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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