Sub RandomPointsInPolygons() Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pFeatureLayer As IFeatureLayer Dim pInFeatureClass As IFeatureClass Dim pOutFeatureClass As IFeatureClass Dim sMessage As String Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap Set pFeatureLayer = pMxDoc.SelectedLayer Set pInFeatureClass = pFeatureLayer.FeatureClass '======================================================================= Dim ET As New ETGW_Core Dim sOutFileName As String Dim sValueField As String Dim lMaxPoints As Long ' The field to get the number of points per polygon sValueField = "status_sub" ' Restrict the max number of points per polygon ' if the value for a polygon in the field above is more than the value set below ' the lMaxPoints will be used lMaxPoints = 20 sOutFileName = "c:\00\RandomPointsInPolygon.shp" Set pOutFeatureClass = ET.RandomPointsInPolygon(pInFeatureClass, sOutFileName, _ sValueField, lMaxPoints, sMessage) '======================================================================== If pOutFeatureClass Is Nothing Then MsgBox sMessage Else Set pFeatureLayer = New FeatureLayer Set pFeatureLayer.FeatureClass = pOutFeatureClass pFeatureLayer.Name = pOutFeatureClass.AliasName pMap.AddLayer pFeatureLayer End If End Sub