Change Data Source Path for Layer Files

Created:10/9/2002
Description:

This sample code demonstrates how to change the path to the data referenced by a Layer File (*.lyr). It shows how to check the type of elements selected in ArcCatalog, and how to use information from a GxDialog to update information for the selected elements.

How to use:
  1. In Windows Explorer, find and double-click the file ToolInstall.bat. This will register the prjChgLyrSrc.dll and place a new command in ArcCatalog's Commands Category.
  2. In ArcCatalog, open the Customize dialog (Tools->Customize).
  3. Click on the ExtraTools category in the Commands tab and drag the "Change Source Of Layer" command to a toolbar
  4. To use: Select a Layer File in ArcCatalog and click on the newly added command button. Navigate to new data source in the dialog and click open. Layer's source path should be updated.

Application:
ArcCatalog

Requires: Layer Files

Difficulty: Moderate


Visual Basic
File Description
clsChgeLyrSrc.cls Class module that implements ICommand interface
modPerformChanges.bas Module containing code for updating a Layer's source data in ArcCatalog
frmErrors.frm Form file containing code to report errors encountered during processing
prjChgLyrSrc.vbp VB Project containing above class module.
prjChgLyrSrc.res Resource file containing bitmap for icon on command button
prjChgLyrSrc.dll Dynamic Link Library made from above code.
ToolInstall.bat Batch file that registers dll with system and with ArcGIS
prjChgLyrSrc.reg File containing info to register above dll with ArcGIS


Key CoClasses: GxDialog, GxObjectFilter, GxLayer, FeatureLayer, GroupLayer
Key Interfaces: IGxDialog, IGxObjectFilter, IGxLayer, IWorkspaceFactory, IFeatureLayer, ICompositeLayer
Key Members: IGxDialog::ObjectFilter, IGxLayer::Layer, ICompositeLayer::Count, IFeatureLayer::FeatureClass