jderekito

9.3 VBA question color from legend of layer

Discussion created by jderekito on Oct 7, 2011
Hello,
I have an old-school 9.3 VBA question that I was hoping someone could help me out with.  I am reading the properties of a layer file w/ VBA. I basically want to get the name of the file, the class breaks ranges and the defined colors (e.g. RGB).  I have everything working except for the color part. I hope someone can help there. Here is my code so far:
Sub ReadingLayers()
  Dim pMxDocument As IMxDocument
  Dim pMap As IMap
  Dim pEnumLayer As IEnumLayer
  Dim pRLayer As IRasterLayer
  Dim pLayer As ILayer
  Dim pGeoFeatLayer As IGeoFeatureLayer
  Dim pId As New UID
  Dim i, j, k As Long
  Dim pLegendInfo As ILegendInfo
  Dim pLegendGroup As ILegendGroup
  Dim pLegendClass As ILegendClass
 
  'COLOR STUFF
  Dim pRasRenCR As IRasterRendererColorRamp
  Dim pCR As IColorRamp
  'Dim pColor As RgbColor
  Dim aColor As IRgbColor
  'Set aColor = New RgbColor
 
  Set pMxDocument = ThisDocument
  Set pMap = pMxDocument.FocusMap
  MsgBox pMap.LayerCount
 
  For i = 0 To pMxDocument.FocusMap.LayerCount - 1
    Set pRLayer = pMap.Layer(i)
    MsgBox pRLayer.Name
    Set pLegendInfo = pRLayer
    Set pLegendGroup = pLegendInfo.LegendGroup(0)
    For j = 0 To pLegendGroup.ClassCount - 1
        MsgBox pLegendGroup.Class(j).Label
    Next
  Next i


  For i = 0 To pMxDocument.FocusMap.LayerCount - 1
    Set pRLayer = pMap.Layer(i)
    Set pRasRenCR = pRLayer.Renderer
    MsgBox pRasRenCR.ColorScheme
  Next i

End Sub

Outcomes