Open Colour Select Dialog Box

High Plains Grifter

Board Regular
Joined
Mar 9, 2010
Messages
129
Hi, People

I am making a macro which uses useforms to guide users through a selection process; one step requires the user to be able to define a colour. To make this friendly and pleasant, I would like to invoke the colour selection dialog box that can be seen by clicking on the fill colour icon in the excel ribbon and then selecting "More Colours". The dialog contains two tabs, one entitled "Standard" and the other "Custom".

My question is this - Can I access this dialog in my macro, and if so, how would I do so to return a colour which can be used later in the macro? I don't necessarily need both tabs; either will do for my porpoises (although I prefer "custom" for it's greater flexibility).

Thanks for your time!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Take a look at:

http://erlandsendata.no/?p=3227

which had the following code:

Code:
Function GetUserSelectedColor(Optional lngInitialColor As Long = 16777215) As Long
Dim lngResult As Long, lngO As Long, intR As Integer, intG As Integer, intB As Integer
    lngResult = xlNone ' default function result
    ' this function requires that a workbook is active
    If Not ActiveWorkbook Is Nothing Then
        ' save the original first palette color so it is possible to restore it
        lngO = ActiveWorkbook.Colors(1)
        ' get the RGB values of lngInitialColor
        intR = lngInitialColor And 255
        intG = lngInitialColor \ 256 And 255
        intB = lngInitialColor \ 256 ^ 2 And 255
        If Application.Dialogs(xlDialogEditColor).show(1, intR, intG, intB) = True Then
            ' the user selected a color and the first color in the palette was updated
            lngResult = ActiveWorkbook.Colors(1)
            ' reset the changed palette color to the original color
            ActiveWorkbook.Colors(1) = lngO
        End If
    End If
    GetUserSelectedColor = lngResult
End Function
 
Upvote 0
Thanks, tlowry - this looks exactly what I was after! I'll try it out over the next few days but I have no doubt that it will give me exactly what I want. The examples on the link you gave me are good as well.

Perfect!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top