I have a button on my toolbar that when clicked, will run a particular model, I have copied the code from here http://resources.esri.com/help/9.3/ArcGISEngine/com_cpp/samples/com/Geoprocessing/5eb001ba-1d6b-4596-b5f8-27c2ad7cb210.htm

But when i click on the button i get the following error. -2147467259 Automation error Unspecified error

My code is as follows

Private Sub LoadExcelToSDE_Click()

On Error GoTo Error:

' Create the geoprocessor
Dim pGp As IGeoProcessor
Set pGp = New GeoProcessor

'Set Overwriteoutput to True
pGp.OverwriteOutput = True

'Add the custom toolbox containing the model tool
'pGp.AddToolbox "H:\Corporate GIS and Web Mapping\Projects\CSY_City_Development   \ArcMapPrototype\City_Development.tbx"
pGp.AddToolbox "C:\Documents and Settings\HalilxS\Application Data\ESRI\ArcToolbox\My Toolboxes\City_Development.tbx"

'create the parameter array
Dim pParamArray As IVariantArray
Set pParamArray = New esriSystem.VarArray

'Populate array of paramaters
'pParamArray.Add "H:\Corporate GIS and Web Mapping\Projects\CSY_City_Development\Data\Developers\UK Developers & Contact Details.xlsx\developers$"
pParamArray.Add "C:\Temp\UK Developers & Contact Details.xlsx\developers"

Dim pResult As IGeoProcessorResult

'Execute the model
Set pResult = pGp.Execute("LoadDevelopers", pParamArray, Nothing)

'Get the returned tool messages
ReturnMessages pResult

MsgBox Err.Number & vbCrLf & Err.Description

End Sub
Public Sub ReturnMessages(ByVal messages As IGeoProcessorResult)

Dim i As Long
Dim message As String

For i = 0 To messages.MessageCount - 1
    message = messages.GetMessage(i)

End Sub

Any ideas on how to fix this, I have tried to change the location of the toolbox and the excel spreadsheet as well but the error still occurs.

I'm using ArcGIS 9.3.1 and VBA

  • On which line do you get the automation error? – Devdatta Tengshe Feb 3 '12 at 18:38
  • This line 'Execute the model Set pResult = pGp.Execute("LoadDevelopers", pParamArray, Nothing) – MapMan Feb 3 '12 at 21:49


This what I would do:

  1. Make sure your model exists in the tool box.
  2. Make sure the model runs with exactly the same parameter (so run it manually) just to be sure.
  3. Make sure you are using the models Name not the label in the Execute method.
  4. I noticed the pathway for your Excel document contains a & symbol, personally I think you are asking for trouble using such symbols in folder names so try moving your model/Excel documents into a simpler folder name like c:\temp.
  5. Does your model use tools that require the workspace environment set?


| improve this answer | |
  • Duncan, 1. Checked 2. Checked 3. Checked (I have called the name and label the same just in case) 4. I have moved the file, but still get the same error. 5. I dont think so, all the model does is copy the rows of an excel spreadsheet to a table in ArcSDE. – MapMan Feb 6 '12 at 10:44
  • 1
    Looking at the code above it looks sound to me and if your model runs without error then I'm not sure whats going on. One other test is to create a simple model (something like count the rows in a table and then place that in a new toolbox and run that instead using your geoprocessor. If that fails too then it would indicate that the source of the problem is at the arcobjects end rather than the model. If it runs then it would suggest there is something odd with the original model. I see you mention that you are copying rows into arcSDE, try a dbase file instead, maybe a permission issue? – Hornbydd Feb 7 '12 at 21:43
  • I did as you suggested and I was still getting the error. I have now got my data to load into SDE by going through each record and using .CreateRowBuffer and then inserting it to the table in SDE. It takes a tad longer but I now have a bit more control. Thanks for you help anyway!!!!! – MapMan Feb 8 '12 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.