<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Strange problem running GP tools from VBA in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754510#M20010</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written a script that runs a GP tool (custom python script) from a CustomUI button in ArcGIS 9.3.1 (ArcView); windows 2000.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that the code runs absolutely perfectly!&amp;nbsp; on this machine...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried moving everything to another PC (same set-up but Windows XP SP3); same folder paths; same ArcGIS install source even but the code does not run.&amp;nbsp; I get a run-time error '-2147467259 (80004005)' automation error unspecified error when it tries to run the GP tool..&amp;nbsp; The tool it's self does run when launched through ArcToolbox, even if using the same parameters.&amp;nbsp; I could not get the tool to run even when I isolated the toolbox code into a sub routine, and hard-coded the variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All the same references are loaded in the document too!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is attached below in case it will help anyone help me!&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Private Sub UIButtonControl1_Click()

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the Geoprocessor object
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim GP As Object
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set GP = CreateObject("esriGeoprocessing.GpDispatch.1")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get current folder (allows for relative positioning)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Current_Folder = Left(Application.Templates.Item(Application.Templates.Count - 1), Len(Application.Templates.Item(Application.Templates.Count - 1)) - Len(ThisDocument.Title))

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'open tool box
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.Toolbox = Current_Folder &amp;amp; "Data\Python\zFEPS.tbx"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; output_folder = "C:\temp\test\"


&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Execute tools
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.scrFepsCopyFepsFromCat "YorkshireIndex", "True", "True", "True", "True", output_folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; ^^^^^^^^^&amp;nbsp;&amp;nbsp; is where the code fails on my XP machine.&amp;nbsp; It all works fine on my win2k machine
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'mergePDFs using PDFTK (http://www.accesspdf.com/pdftk/)
&amp;nbsp;&amp;nbsp;&amp;nbsp; (subsequent code will not have any effect - it's only shell and file system object stuff)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
End Sub

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Jun 2010 13:25:04 GMT</pubDate>
    <dc:creator>MarkWhitling</dc:creator>
    <dc:date>2010-06-10T13:25:04Z</dc:date>
    <item>
      <title>Strange problem running GP tools from VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754510#M20010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written a script that runs a GP tool (custom python script) from a CustomUI button in ArcGIS 9.3.1 (ArcView); windows 2000.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that the code runs absolutely perfectly!&amp;nbsp; on this machine...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried moving everything to another PC (same set-up but Windows XP SP3); same folder paths; same ArcGIS install source even but the code does not run.&amp;nbsp; I get a run-time error '-2147467259 (80004005)' automation error unspecified error when it tries to run the GP tool..&amp;nbsp; The tool it's self does run when launched through ArcToolbox, even if using the same parameters.&amp;nbsp; I could not get the tool to run even when I isolated the toolbox code into a sub routine, and hard-coded the variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All the same references are loaded in the document too!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is attached below in case it will help anyone help me!&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Private Sub UIButtonControl1_Click()

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the Geoprocessor object
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim GP As Object
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set GP = CreateObject("esriGeoprocessing.GpDispatch.1")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get current folder (allows for relative positioning)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Current_Folder = Left(Application.Templates.Item(Application.Templates.Count - 1), Len(Application.Templates.Item(Application.Templates.Count - 1)) - Len(ThisDocument.Title))

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'open tool box
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.Toolbox = Current_Folder &amp;amp; "Data\Python\zFEPS.tbx"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; output_folder = "C:\temp\test\"


&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Execute tools
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.scrFepsCopyFepsFromCat "YorkshireIndex", "True", "True", "True", "True", output_folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; ^^^^^^^^^&amp;nbsp;&amp;nbsp; is where the code fails on my XP machine.&amp;nbsp; It all works fine on my win2k machine
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'mergePDFs using PDFTK (http://www.accesspdf.com/pdftk/)
&amp;nbsp;&amp;nbsp;&amp;nbsp; (subsequent code will not have any effect - it's only shell and file system object stuff)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
End Sub

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jun 2010 13:25:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754510#M20010</guid>
      <dc:creator>MarkWhitling</dc:creator>
      <dc:date>2010-06-10T13:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Strange problem running GP tools from VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754511#M20011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;sorry for shameless plug, but I am really struggling with this one.&amp;nbsp; Is there any other way of calling the GP object that I have missed that may perhaps work under XP?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jun 2010 06:16:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754511#M20011</guid>
      <dc:creator>MarkWhitling</dc:creator>
      <dc:date>2010-06-29T06:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Strange problem running GP tools from VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754512#M20012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;sorry for shameless plug, but I am really struggling with this one.&amp;nbsp; Is there any other way of calling the GP object that I have missed that may perhaps work under XP?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you certain that your CurrentFolder variable is what you think it is?&amp;nbsp; When I try your code in ArcMap 9.3.1 SP1 under Windows XP SP 3 using the project file D:\Untitled.mxd, what I get for ThisDocument.Title is "Normal.mxt". That of course means that CurrentFolder gets the wrong value, which means that the Geoprocessor object is going to have the wrong path to your toolbox.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jun 2010 16:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754512#M20012</guid>
      <dc:creator>JoeVondracek</dc:creator>
      <dc:date>2010-06-29T16:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Strange problem running GP tools from VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754513#M20013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi There,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I checked my code, and with the sample being pasted into ThisDocument as a simple sub routine, I get the full path.. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See attached screen capture&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So still no joy I'm afraid!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jul 2010 06:57:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754513#M20013</guid>
      <dc:creator>MarkWhitling</dc:creator>
      <dc:date>2010-07-02T06:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Strange problem running GP tools from VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754514#M20014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmm.&amp;nbsp; Well, I don't know why your code isn't working, but the following works for me using ArcGIS 9.3.1 sp1 on Windows XP.&amp;nbsp; I have a toolbox named "Test Tools" that has a simple model in it, named "TestTool", which simply copies the input shapefile to the output shapefile.&amp;nbsp; I *think* that GPDispatch is the old way of doing things (pre 9.2) and ESRI recommends that you now use the Geoprocessor class instead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Private Sub UIButtonControl1_Click()
&amp;nbsp;&amp;nbsp; 'Create the Geoprocessor object
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim GP As IGeoProcessor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set GP = New GeoProcessor

&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get current folder (allows for relative positioning)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Current_Folder = Left(Application.Templates.Item(Application.Templates.Count - 1), Len(Application.Templates.Item(Application.Templates.Count - 1)) - Len(ThisDocument.Title))
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.OverwriteOutput = True
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.AddToolbox (Current_Folder &amp;amp; "Test Tools.tbx")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; '//Declare and set a variant array to hold the parameters
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim parameters As IVariantArray
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set parameters = New VarArray
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; '//Populate the variant array with parameters
&amp;nbsp;&amp;nbsp;&amp;nbsp; parameters.Add "C:\temp\x.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; parameters.Add "C:\temp\y.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; '//There is a custom model named TestTool in the custom toolbox Test Tools.
&amp;nbsp;&amp;nbsp;&amp;nbsp; '//All it does is copy the first shapefile to a second shapefile, both of
&amp;nbsp;&amp;nbsp;&amp;nbsp; '//which are parameters to the model.
&amp;nbsp;&amp;nbsp;&amp;nbsp; GP.Execute "TestTool", parameters, Nothing
End Sub
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:00:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754514#M20014</guid>
      <dc:creator>JoeVondracek</dc:creator>
      <dc:date>2021-12-12T08:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Strange problem running GP tools from VBA</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754515#M20015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know this is an old thread, but I am having the exact same problem, I have tried the code above this post, but I still get the automation error message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 12:49:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/strange-problem-running-gp-tools-from-vba/m-p/754515#M20015</guid>
      <dc:creator>HalilSiddique</dc:creator>
      <dc:date>2012-02-07T12:49:41Z</dc:date>
    </item>
  </channel>
</rss>

