Link to home
Start Free TrialLog in
Avatar of progtw
progtw

asked on

I need a color picker for use with Word VBA (2000 and up on Windows 2000 and XP).

Hi all,

I need a color picker for use with Word VBA (2000 and up on Windows 2000 and XP). Like the WIndows/Office Colors dialog box.

It must let you choose a color and return the 24-bit value.

thanks,

avi
Avatar of moorhouselondon
moorhouselondon
Flag of United Kingdom of Great Britain and Northern Ireland image

Ah, sorry, you wanted to do this within VBA.
Avatar of rockiroads
Avatar of progtw
progtw

ASKER

to rockiroads:

I think you have given me a link to utilities which allow me to pick a color from whatever *happens* to be in screen.  

I meant something else. What I meant was a color selector of the type that you see a lot in Windows and Office. There is a dialog box called Colors which allows you to select any color of the rainbow, or make your own by giving RGB values while seeing whast they look like in the sample window. And there are two tabs. One contains a preset pallette of "honeycomb" colored hex shapes. And the other tab gives you the full range of all colors and hues etc. We use thme to set font colors or fill colors. I am sure that this dialog box must be available vrom in Windows, but I don't know how to access it. I want to access such a function using VBA to return me the user's color selection.

tia

avi
The links are to Active X controls in which you can make use of in code.

I know what you mean, the only way possibly is if you include the common api dialog


ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of progtw

ASKER

So far so good it seems to work.

Am I supposed to be able to see an entry for comdlg32 in the VBA Object Browser?

avi
I dont know if u have to add it as a reference.
But since the code I posted makes use of it as a API function instead, there is no reason to worry about references
Avatar of progtw

ASKER

Sorry about the delay.
You mean the function is a Windows "kernel" API function? (I don't know if the word "kernel" is the right way of saying this.)

avi
Well kernel is more system. Windows is just full of lots of dll's. This code just making use of one of them. I believe this dll is shipped with windows as it contains common dialogs used by windows
Avatar of progtw

ASKER

'scuse me for picking your brains some more (well you are getting 500 points...), but pray explain to me, why do some things have to be "referenced" (ie add a reference to them) and other things, like functions in the Windows DLLs as you mention, do not require a reference to them?

Oh, and where can see a list of the functions in comdlg32.dll?

tia

avi
I'll try to explain, I know why, I just aint that great in explaining
If you add a reference to a library, it means your code can access all the methods available in that dll
You cannot use something in that dll unless u reference it somehow


Where can a list of funcs be found in comdlg32? I dont know, I only have used it for a few things
Avatar of progtw

ASKER

thnx

>> You cannot use something in that dll unless u reference it somehow
But earlier you wrote, and I quote, "But since the code I posted makes use of it as a API function instead, there is no reason to worry about references".
?

tia

avi
Avatar of progtw

ASKER

Ok, now I think I understand. The API function declaration code you wrote (quoted below) is the reference:

Private Declare Function ChooseColor Lib "comdlg32.dll" _
   Alias "ChooseColorA" _
  (lpcc As CHOOSECOLORSTRUCT) As Long

?

avi
Yes, I am sepcifically defining what function to use in that DLL

Sorry about the confusion with references earlier. I meant actually adding a reference (Tools/References) as opposed to specifying a DLL function to use via code
Avatar of progtw

ASKER

Thanks,

I finally got around to testing it out by pickin a color and using it to shade a selection in a doc. Works. Great!

avi