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
    MsgBox pGP.GetMessages(), vbOKOnly, "Test"
End Sub 
  • Edited code formatting.
    – Petr Krebs
    Dec 27 '10 at 20:47
  • i haven't done vba in a long time, but i thought string concatenation was with & not +
    – gotchula
    Dec 27 '10 at 21:10
  • @gotchula: That's right. Must be VB.NET then..
    – Petr Krebs
    Dec 27 '10 at 23:43
  • Try using a full unit string for tolerance, so "1 meter" versus "1". Dec 28 '10 at 5:27
  • Added a vb tag.
    – djq
    Dec 28 '10 at 12:38

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:


Your Answer

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