Sub Split_ByAttributes() Dim ET As New ETGW_Core 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 = ET.GetLayerByName("counties", pMap) If pFeatureLayer Is Nothing Then MsgBox "Layer not found" Exit Sub End If Set pInFeatureClass = pFeatureLayer.FeatureClass '======================================================================= Dim sOutDir As String Dim sPrefix As String, sNameField As String Dim bAddLayer As Boolean 'the output file names will be generated using the preffix and the name field 'if the prefix = 'counties' and the name_field = 'STATE_NAME' the files generated will have names: ' counties_Nevada.shp ' counties_Manitobe.shp ' ....... sPrefix = "counties" sNameField = "STATE_NAME" If pInFeatureClass.FindField(sNameField) = -1 Then MsgBox "Field not found" Exit Sub End If '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.SplitByAttributes(pInFeatureClass, sOutDir, _ sPrefix, sNameField, _ bAddLayer, pMap) '======================================================================== Exit Sub EH: MsgBox Err.Description End Sub