mrstephenbell

Select Layer By Attribute

Discussion created by mrstephenbell on Dec 22, 2011
Latest reply on Dec 22, 2011 by bruce.nielsen
Good morning everyone,

I am using geoprocessing within VBA (9.3 environment).  I am getting an automation error when trying to select attributes of a layer.  I have included code that I am trying.  Any thoughts?

Dim GP As Object
Set GP = CreateObject("esriGeoprocessing.GPDispatch.1")

GP.AddToolbox "C:/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx"

GP.AddToolbox "C:/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx"


GP.OverwriteOutput = True


GP.MakeXYEventLayer_management "C:\File\Structure\tables\table.dbf", "Longitude", "Latitude", "Output_Layer", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];IsHighPrecision"

GP.FeatureClassToShapefile_conversion "Output_Layer", "C:\File\Structure"


GP.Project_management "C:\File\Structure\Output_Layer.shp", "C:\File\Structure\New_Output.shp", "PROJCS['British_National_Grid',GEOGCS['GCS_OSGB_1936',DATUM['D_OSGB_1936',SPHEROID['Airy_1830',6377563.396,299.3249646]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',400000.0],PARAMETER['False_Northing',-100000.0],PARAMETER['Central_Meridian',-2.0],PARAMETER['Scale_Factor',0.9996012717],PARAMETER['Latitude_Of_Origin',49.0],UNIT['Meter',1.0]]", "OSGB_1936_To_WGS_1984_Petroleum", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]"


GP.SelectLayerByAttribute_management "C:\File\Structure\New_Output.shp", "NEW_SELECTION", "TYPE = 'W'"


The Feature Class To Shp was put in to try and solve the problem, but didn't, so I realise that might not need to exist.  The final shp is created but the selection is not run on it.

Many thanks in advance
Stephen

Outcomes