80004005 Error Collect Events with Render script

Discussion created by joshuamoloney on Nov 16, 2011

I have the following script which integrates points then collects events with render. Problem is the collect events with render part causes a 80004005 error (unspecified). Could you please have a look at my script and let me know where I have gone wrong? The Integrate part (with user tolerance) works fine, it is just the last collect event with render part that fails.

' Create the Geoprocessor object
set gp = WScript.CreateObject("esriGeoprocessing.GPDispatch.1")

' Load required toolboxes...
gp.AddToolbox "D:/ArcGIS/ArcToolbox/Toolboxes/Spatial Statistics Tools.tbx"
gp.AddToolbox "D:/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx"

'setup a dialog box to get the shapefile
'dialog box
Dim ObjFSO, InitFSO

' create an instance of the File Browser
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

'setup the File Browser specifics
ObjFSO.Filter = "Shapefiles|*.shp|Text Files|*.txt|All Files|*.*"
ObjFSO.FilterIndex = 1
ObjFSO.InitialDir = "D:\Data"

' show the file browser and return the selection (or lack of) to InitFSO
InitFSO = ObjFSO.ShowOpen

If InitFSO = False Then
    Wscript.Echo "Script Error: Please select a shapefile next time!"
     TheShapefile = objfso.filename
 Output_Features = left(TheShapefile,len(TheShapefile)-4) & "_integrated.shp"
End If

'get the fodler name for later
theFolder = left(theshapefile,instrrev(theshapefile,"\")-1)

'get the actual shapefile name for later use
Fname = left(right(theshapefile, len(theshapefile) - instrrev(theshapefile,"\")),len(right(theshapefile, len(theshapefile) - instrrev(theshapefile,"\")))-4)

'get the tolerance and check if it is a number

a = inputbox("What tolerance would you like?")

if not isnumeric(a) then
 msgbox "Tolerance must be a number...quitting",vbcritical,"Error"
elseif not len(a) > 0 then
 msgbox "Tolerance must be a number...quitting",vbcritical,"Error"
end if 

'create the layer and shapefile names for the collect events with render

Output_Layer_File = left(TheShapefile,len(TheShapefile)-4) & "_" & a & "_metres"
Output_Weighted_Point_Feature_Class = left(TheShapefile,len(TheShapefile)-4) & "_" & a & "_metres.shp"

'integrate vars
a = a & " Meters"
b = theshapefile & " #"

'create a copy of the shapefile in case an error is made
set FSO = wscript.createobject("scripting.filesystemobject")
set FF = fso.getfolder(thefolder)
 for each file in FF.files
  if left(,len( = Fname then
   fso.copyfile, left(,len( & "_backup." & right(,3)
  end if

' Process: Integrate...
gp.Integrate_management b, a

' Process: Collect Events with Rendering...
gp.CollectEventsRendered_stats theshapefile, Output_Layer_File, Output_Weighted_Point_Feature_Class '<---------------this is where the error occurs

msgbox "Success!"