English

How To: Populate the SymbolSelector dialog

Summary

Note:
This article pertains to ArcGIS versions 8.x and 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.

Instead of having default values and colors appear in the Symbol Selector dialog, you may want to populate the dialog with custom symbols, colors, and sizes.

Note: 
Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward

Procedure

  1. Start ArcMap.
  2. Create a new UIButtonControl: How To: Create a new UIButtonControl​
Note:
For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
  1. Right-click the UIButtonControl and select View Source.
  2. Copy this code into the UIButtonControl's click event.
Dim pSymbolSelector As ISymbolSelector
Dim pMarkerIn As IMarkerSymbol
Dim pMarkerOut As IMarkerSymbol
Dim pSymbol As ISymbol
Dim pColorIn As IRgbColor
Dim pRGBColorOut As IRgbColor
  
Set pMarkerIn = New CharacterMarkerSymbol
Set pSymbolSelector = New SymbolSelector

Set pColorIn = New RgbColor
pColorIn.Red = 25
pColorIn.Green = 25
pColorIn.Blue = 150

pMarkerIn.Color = pColorIn
pMarkerIn.Angle = 45
pMarkerIn.Size = 15
' X and Y Offset values are not persisted.
' This is a known issue.
'  pMarkerIn.XOffset = -5
'  pMarkerIn.YOffset = 2

pSymbolSelector.AddSymbol pMarkerIn

If pSymbolSelector.SelectSymbol(0) Then
   '   The SymbolSelect Dialog popped up
    Set pSymbol = pSymbolSelector.GetSymbolAt(0)
      
   ' Capture the values set by the user
    Set pMarkerOut = pSymbol
    Set pRGBColorOut = pMarkerOut.Color
Else
    MsgBox "User cancelled"
End If
  1. Click the button to run the code.
Note:
Values for the XOffset and YOffset propeties of the symbol object do not persist.  This is a known issue.