API Documentation > CorelDRAW > 2025-v26 > Palettes > IVGPalettes
Palettes.CreateFromSelection method
Creates a color palette from selected shapes
Syntax:
Function CreateFromSelection(ByVal Name As String, Optional ByVal FileName As String, Optional ByVal Overwrite As Boolean = False) As Palette
Parameters:
Name Type Description
Name
String
FileName
String
Overwrite
Boolean
Specifies whether to overwrite the default palette. If this parameter is set to True, the new palette replaces the default palette. If it is set to False, the new palette coexists with the default palette.
Remarks:
The CreateFromSelection method creates a new custom color palette based on the colors used in a selection of objects.
Examples:
The following VBA example displays the number of colors used in the selection.
Sub Test()
Dim pal As Palette
Set pal = Palettes.CreateFromSelection("Selection Colors", _
  Application.UserDataPath & "Palettes\SelectionColors.xml", True)
MsgBox "The selection uses " & pal.ColorCount & " colors"
pal.Close 
End Sub