[GIS] ArcMap Geoprocessing VBA code/tool – smooth polygon

arcobjectserror-000628geoprocessingvb.net

I would like to execute the smoothpolygon tool within ArcMap VBA and I'm having some trouble defining the parameters syntax for the tool. I'm getting this error below:

ERROR 000622: Failed to execute (mooth Polygon). Parameters are not valid.
ERROR 000628: Cannot set input into parameter tolerance.

Here is my code:

Private Sub SmoothGeo_Click()

    Dim filePath As String
    filePath = "C:\Projects\OSU_Well_Buffer_Tool\USDE\USDE.mdb"
    Dim inputName As String
    Dim clipName As String
    inputName = "buffer9_smu"

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

    On Error GoTo EH
    pGP.Workspace = filePath
    ' note: the inputs can also be objects; however the output must be a string.
    pGP.smoothpolygon_management filePath + "\" + inputName, "C:\Projects\OSU_Well_Buffer_Tool\USDE\USDE.mdb\smooth", "1", "PAEK", "150"

    Exit Sub
EH:
    MsgBox pGP.GetMessages(), vbOKOnly, "Test"
End Sub 

Best Answer

A better way to execute tools in VB, VBA, or .NET is to use the IGeoProcessor interface, rather than the dispatch object.

This link will take you to a sample of using the IGeoProcessor in VB/VBA to execute tools and return the tool messages:

http://edndoc.esri.com//arcobjects/9.2/CPP_VB6_VBA_VCPP_Doc/COM_Samples_Docs/Geoprocessing/1B3C4460-293A-4E3B-9972-400C19A84953.htm

Related Question