(view source code of comdlgcp.vbs as plain text)
' A script to demonstrate the Color Picker dialog available in COMDLG32.OCX' Written by Rob van der Woude' http://www.robvanderwoude.comOption ExplicitDim intColorintColor = ColorPicker( )
If Err Then
WScript.Echo "Error: " & Err.Description
ElseWScript.Echo "Selected color (RGB): " & RGB( intColor )
End If
Function ColorPicker( )
Dim objDialog ' Default value if abortedColorPicker = 0
On Error Resume Next
Set objDialog = CreateObject( "MSComDlg.CommonDialog" )
If Err Then
MsgBox Err.Description & vbCrLf & vbCrLf & "This script requires COMDLG32.OCX." & vbCrLf & vbCrLf & "Please make sure it is installed and registered.", , "COMDLG32 not registered"
ElseobjDialog.ShowColor
ColorPicker = CLng( objDialog.Color )
End If
Set objDialog = Nothing
End Function
Function RGB( myColor )
Dim intTest, strRed, strGreen, strBluestrRed = CStr( myColor Mod 256 )
intTest = Int( myColor / 256 )
strGreen = CStr( intTest Mod 256 )
intTest = Int( intTest / 256 )
strBlue = CStr( intTest Mod 256 )
RGB = strRed & " " & strGreen & " " & strBlue
End Function
page last modified: 2025-10-11; loaded in 0.0070 seconds