2

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 
  • 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". – Jason Scheirer Dec 28 '10 at 5:27
  • Added a vb tag. – djq Dec 28 '10 at 12:38
4

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

Your Answer

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