Tuesday, December 13, 2016

Creating New Color Palette With Macro

Creating Color Palette With Vba Codes



       If you want, you can also create new hues with this color palette.
   
The codes we assign to button on the worksheet:
"
...
Public Function Execute() As Boolean
  Dim cc As TChooseColor
  Dim Ret As Long

  With cc
    .lStructSize = Len(cc)
    .hwndOwner = Application.Hwnd
    .lpCustColors = String$(64, vbNullChar)
    .flags = 0
    If RGBINIT Then .flags = .flags + CC_RGBINIT
    If FULLOPEN Then .flags = .flags + CC_FULLOPEN
    If PREVENTFULLOPEN Then .flags = .flags + CC_PREVENTFULLOPEN
    If SHOWHELP Then .flags = .flags + CC_SHOWHELP
    .rgbResult = Color
    Ret = ChooseColor(cc)
    If Ret = 0 Then
      Execute = False
    Else
      If .rgbResult > RGB(255, 255, 255) Then
        Execute = False
      Else
        Execute = True
        Selection.Interior.Color = .rgbResult
      End If
    End If
  End With
End Function

Sub ColorTime()
Call Execute
End Sub
...
"