title: Excel 64-bit and comdlg32.dll custom colours
body: <p>I'm trying to adapt the code in either <a href="http://support.microsoft.com/kb/153929" rel="nofollow noreferrer">here</a>  or <a href="http://www.cpearson.com/Excel/Colors.aspx" rel="nofollow noreferrer">here</a> to open the custom colour palette in Excel 2010 64-bit but cannot get it to work. Code on both sites work fine in Excel 2003</p>
  
  <p>One attempt</p>
  
  <pre><code> Option Explicit
  
   Private Type CHOOSECOLOR
   lStructSize As Long
   hwndOwner As Long
   hInstance As Long
   rgbResult As Long
   lpCustColors As String
   flags As Long
   lCustData As Long
   lpfnHook As Long
   lpTemplateName As String
   End Type
  
   Private Declare PtrSafe Function ChooseColorAPI Lib "comdlg32.dll" Alias _
   "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
  
   Dim CustomColors() As Byte
  
   Private Sub Command1_Click()
     Dim cc As CHOOSECOLOR
     Dim Custcolor(16) As Long
     Dim lReturn As Long
     cc.lStructSize = Len(cc)
     cc.hwndOwner = Application.Hwnd
     cc.hInstance = 0
     cc.lpCustColors = StrConv(CustomColors, vbUnicode)
     cc.flags = 0
     lReturn = ChooseColorAPI(cc)
     If lReturn &lt;&gt; 0 Then
         Application.Caption = "RGB Value User Chose: " &amp; Str$(cc.rgbResult)
         Application.BackColor = cc.rgbResult            ' Visual Basic only ****
         Application.Section(0).BackColor = cc.rgbResult ' Access only **********
         CustomColors = StrConv(cc.lpCustColors, vbFromUnicode)
     Else
         MsgBox "User chose the Cancel Button"
     End If
     End Sub
  
     Private Sub Form_Load()
     ReDim CustomColors(0 To 16 * 4 - 1) As Byte
     Dim i As Integer
  
     For i = LBound(CustomColors) To UBound(CustomColors)
         CustomColors(i) = 0
     Next i
     End Sub
  </code></pre>
  
  <p>This runs ok but doesn't show the dialog. I've also tried changing some LONG types to LONGPTR with no success. Does anyone know how to get this working on a 64-bit machine; or if it's even possible? Perhaps there's a new library?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit:</strong> Slight rewording with offer of bounty...
  How do I access and use this custom colour chooser (image below) in Excel 2010 64-bit (MUST work on 64-bit!) to set cells in Excel 2010 with the colour chosen and store the colour? The image is taken from Excel 2010 64-bit by selecting fill button>more colors>Custom</p>
  
  <p><a href="http://img851.imageshack.us/img851/2057/unlednvn.png" rel="nofollow noreferrer">Valid XHTML http://img851.imageshack.us/img851/2057/unlednvn.png</a></p>