HOW TO
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.
Instructions provide a code sample that shows how to toggle the visibility of the Table of Contents legend for a group layer or LYR file.
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
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Dim pMxDoc As IMxDocument Dim pGroupLayer As IGroupLayer Dim pLayer As ILayer Dim pLegendInfo As ILegendInfo Dim pLegendGroup As ILegendGroup Set pMxDoc = ThisDocument Set pLayer = pMxDoc.SelectedLayer If Not TypeOf pLayer Is IGraphicsLayer Then If TypeOf pLayer Is IGroupLayer Then Set pGroupLayer = pLayer pGroupLayer.Expanded = Not pGroupLayer.Expanded Else Set pLegendInfo = pLayer Set pLegendGroup = pLegendInfo.LegendGroup(0) pLegendGroup.Visible = Not pLegendGroup.Visible End If pMxDoc.ActiveView.Refresh pMxDoc.UpdateContents End If
Article ID:000006267
Get help from ArcGIS experts
Download the Esri Support App