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.
In ArcMap, you can right-click on a layer to display its properties. The source tab displays the source name of the layer even when the layer has been renamed in the Table of Contents (TOC). This article illustrates how to return the source name for a raster layer using ArcObjects.
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 pApp As IApplication Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pLayer As ILayer Dim pRasterLayer As IRasterLayer Dim pRaster As IRaster Dim pRasterBandColl As IRasterBandCollection Dim pEnumRasterBand As IEnumRasterBand Dim pRasterBand As IRasterBand Dim pRasterDataset As IRasterDataset Dim pDataset As IDataset Set pApp = Application Set pMxDoc = pApp.Document Set pMap = pMxDoc.FocusMap Set pLayer = pMap.Layer(0) Set pRasterLayer = pLayer ' QI Debug.Print "LayerName: " & pLayer.Name Set pRaster = pRasterLayer.Raster Set pRasterBandColl = pRaster ' QI Set pEnumRasterBand = pRasterBandColl.Bands pEnumRasterBand.Reset 'Set pRasterBand = pRasterBandColl.BandByName("Band_1") Set pRasterBand = pEnumRasterBand.Next Do Until pRasterBand Is Nothing Set pRasterDataset = pRasterBand.RasterDataset Set pDataset = pRasterDataset ' QI Debug.Print "Dataset.Name: " & pDataset.Name Set pRasterBand = pEnumRasterBand.Next Loop
Article ID:000005873
Get help from ArcGIS experts
Download the Esri Support App