Showing the standard XL Colour chart

R

Richard Buttrey

Hi,

From within a VBA Form I need to open up the standard Excel colour
chart so that the user can make a selection which will become a
variable I use elsehwere in the code.

Can someone point me in the right direction please.

Many thanks.


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 
T

Tom Ogilvy

Are you talking about showing this:

Application.Dialogs(xlDialogPatterns).Show

or This

Application.Dialogs(xlDialogColorPalette).Show

These are not generic color picker dialogs. The don't return the Selection.
Bob Phillips has posted code like this which actually colors a cell and then
gets the color of the cell:

'-----------------------------­------------------------------­
Function GetColorindex(Optional Text As Boolean = False) As Long
'-----------------------------­------------------------------­

Dim rngCurr As Range


Set rngCurr = Selection
Application.ScreenUpdating = False
Range("IV1").Select
Application.Dialogs(xlDialogPatterns).Show
GetColorindex = ActiveCell.Interior.ColorIndex
If GetColorindex = xlColorIndexAutomatic And Not Text Then
GetColorindex = xlColorIndexNone
End If
ActiveCell.Interior.ColorIndex = xlColorIndexAutomatic
rngCurr.Select
Set rngCurr = ActiveSheet.UsedRange
Application.ScreenUpdating = True
End Function
 
B

Bob Phillips

'-----------------------------­------------------------------­--------------
--
Function GetColorindex(Optional Text As Boolean = False) As Long
'-----------------------------­------------------------------­--------------
--
Dim rngCurr As Range

Set rngCurr = Selection
Application.ScreenUpdating = False
Range("IV1").Select
Application.Dialogs(xlDialogPatterns).Show
GetColorindex = ActiveCell.Interior.ColorIndex
If GetColorindex = xlColorIndexAutomatic And Not Text Then
GetColorindex = xlColorIndexNone
End If
ActiveCell.Interior.ColorIndex = xlColorIndexAutomatic
rngCurr.Select
Set rngCurr = ActiveSheet.UsedRange
Application.ScreenUpdating = True
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)
 
M

malik641

This should get you started:

Application.Dialogs.Item(xlDialogColorPalette).Show

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top