# Microsoft Office Application Help - Excel Help forum > Excel Programming / VBA / Macros >  >  Excel color-pick eye dropper

## globalpontoon

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?

----------


## Leith Ross

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.

----------


## globalpontoon

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.

----------


## Leith Ross

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.

----------


## globalpontoon

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.

----------


## Andy Pope

Here is one I made a while ago.

----------


## globalpontoon

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

----------


## Bradley Beacham

Very nice. Thank you for this.

----------


## Beerholder

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

----------


## Andy Pope

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

----------


## arinberkan

> 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.
```

----------


## AliGW

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

----------

