Sub Split_ByLocation() Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pMapSref As ISpatialReference Dim pFeatureLayer As IFeatureLayer Dim pInFeatureClass As IFeatureClass Dim bDone As Boolean On Error GoTo EH Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap Set pMapSref = pMap.SpatialReference Set pFeatureLayer = pMxDoc.SelectedLayer If pFeatureLayer Is Nothing Then MsgBox "Select a layer in the TOC" Exit Sub End If Set pInFeatureClass = pFeatureLayer.FeatureClass '======================================================================= Dim ET As New ETGW_Core Dim sOutDir As String Dim dFuzzyTol As Double Dim pClipLayer As IFeatureLayer Dim pClipFeatureClass As IFeatureClass Dim sPrefix As String, sNameField As String Dim bAddLayer As Boolean Set pClipLayer = ET.GetLayer("states") If pClipLayer Is Nothing Then Exit Sub End If 'the output file names will be generated using the preffix and the name field from the clip feature class 'if the prefix = 'rivers' and the name_field = 'STATE_NAME' the files generated will have names: ' rivers_Nevada.shp ' rivers_Manitobe.shp ' ....... sPrefix = "rivers" sNameField = "STATE_NAME" Set pClipFeatureClass = pClipLayer.FeatureClass If pClipFeatureClass.FindField(sNameField) = -1 Then MsgBox "Field not found" Exit Sub End If 'set the fuzzy tolerance dFuzzyTol = 0.0002 'set the output folder sOutDir = "c:\000" 'if bAddLayer = True the resulting datasets will be added to the map. 'this requires a map object to be passed to the function bAddLayer = True bDone = ET.SplitByLocation(pInFeatureClass, pClipFeatureClass, _ sOutDir, dFuzzyTol, sPrefix, sNameField, _ bAddLayer, pMap) '======================================================================== Exit Sub EH: MsgBox Err.Description End Sub