Change the selection colors for a table


Instructions provided describe how to change the selection colors for a table.


  1. Start ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument then right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    Code in the Project's ThisDocument code module will only run in the current map document. If you want to store the code in all your map documents open the Normal.mxt ThisDocument code module instead.

  4. Copy the following code into the code module.

    Sub SwitchTableProps()

    Dim pTableView As ITableView
    Dim pApp As IApplication
    Dim pTabWin As ITableWindow
    Dim pDoc As IMxDocument
    Dim pTableProps As ITableProperties
    Dim pTableProp As ITableProperty
    Dim pTableSelectionColor As ITableSelectionColor

    'Get the table properties from the document
    Set pDoc = ThisDocument
    Set pTableProps = pDoc.TableProperties

    'Create new table properties
    Set pTableProp = New TableProperty
    'Get the first map in the document
    Dim pLayer As IFeatureLayer
    Set pLayer = pDoc.FocusMap.Layer(0)
    Set pTableProp.Table = pLayer.FeatureClass
    'Change the tables appearance
    Set pTableProp.FeatureLayer = pLayer

    'set the regular color of the selection
    Set pTableProp.SelectionColor = BuildRGB(0, 255, 0)

    pTableProps.Add pTableProp
    Set pTableSelectionColor = pTableProps

    'set the colour of the selection when only the selected features are being shown
    Set pTableSelectionColor.SelectedTableSelectionColor = BuildRGB(255, 0, 0)

    'Display the window
    Set pApp = Application
    Set pTabWin = New TableWindow
    Set pTabWin.FeatureLayer = pLayer
    Set pTabWin.Application = Application
    pTabWin.ShowSelected = False
    pTabWin.TableSelectionAction = esriSelectFeatures
    pTabWin.Show True

    End Sub
    Private Function BuildRGB(pRed As Long, pGreen As Long, pBlue As Long) As IColor
    Dim pRGB As IRgbColor
    Set pRGB = New RgbColor
    With pRGB
    .Red = pRed
    .Blue = pBlue
    .Green = pGreen
    .UseWindowsDithering = True
    End With
    Set BuildRGB = pRGB
    End Function

  5. Close the Visual Basic Editor.
  6. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000007078

  • ArcMap 8 x
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic