Option Explicit
Private Declare Function ChooseColor_Dlg Lib "comdlg32.dll" _
Alias "ChooseColorA" (pcc As CHOOSECOLOR_TYPE) As Long
Private Type CHOOSECOLOR_TYPE
lStructSize As Long
hwndOwner As Long
hInstance As Long
rgbResult As Long
lpCustColors As Long
flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Const CC_ANYCOLOR = &H100
Private Const CC_ENABLEHOOK = &H10
Private Const CC_ENABLETEMPLATE = &H20
Private Const CC_ENABLETEMPLATEHANDLE = &H40
Private Const CC_FULLOPEN = &H2
Private Const CC_PREVENTFULLOPEN = &H4
Private Const CC_RGBINIT = &H1
Private Const CC_SHOWHELP = &H8
Private Const CC_SOLIDCOLOR = &H80
Sub Gribouillage()
Dim CC_T As CHOOSECOLOR_TYPE, Retval As Variant
Static BDF(16) As Long
BDF(0) = RGB(0, 255, 0) 'first defined color
BDF(1) = RGB(255, 0, 0) 'second defined color
BDF(2) = RGB(0, 0, 255) 'third defined color
With CC_T
.lStructSize = Len(CC_T)
.flags = CC_RGBINIT Or CC_ANYCOLOR Or CC_FULLOPEN Or _
CC_PREVENTFULLOPEN
.rgbResult = RGB(0, 255, 0)
.lpCustColors = VarPtr(BDF(0))
End With
Retval = ChooseColor_Dlg(CC_T)
If Retval <> 0 Then
'/////////////// ajout pour test
ActiveCell.Interior.Color = CC_T.rgbResult
With ActiveSheet.Shapes.AddShape(1, 80, 80, 237, 80)
.Fill.ForeColor.RGB = CC_T.rgbResult
End With
'/////////////// fin ajout pour test
End If
End Sub