<?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 Re: Running python script from VBA code in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63664#M2256</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Lorna;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why would you use VBA to program a GUI, when an interface that looks like the image I've attached can easily be built within the toolbox? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Nov 2010 23:34:53 GMT</pubDate>
    <dc:creator>JeffLee</dc:creator>
    <dc:date>2010-11-05T23:34:53Z</dc:date>
    <item>
      <title>Running python script from VBA code</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63663#M2255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now that my python script is working (from ArcToolbox) I'd like to set it up to run from my VBA code.&amp;nbsp; The code essentially provides an interface for the user to input the parameters that the script requires. Here are the important snippets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VBA:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Dim Parameters As IVariantArray
Set Parameters = New VarArray

Parameters.Add CatchFile
Parameters.Add LandCover
Parameters.Add "H:\TEMP"
Parameters.Add LCTabOutF
Parameters.Add txtboxOutTabN.Value

Dim gp As Object
Set gp = CreateObject("esriGeoprocessing.GpDispatch.1")
gp.AddToolbox ("F:/Hydrology_Tools/Toolboxes/CatchmentDelineation.tbx")
gp.Execute "LandCover", Parameters, Nothing ' Automation error, unspecified error&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import Modules
import arcgisscripting
# Create Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = True
# Set up parameters
catchmentsFC = gp.GetParameterAsText(0) #in a toolbox GUI, Type = FeatureLayer
landCoverFC = gp.GetParameterAsText(1) #in a toolbox GUI, Type = FeatureLayer
tempWorkspace = gp.GetParameterAsText (2) #in a toolbox GUI, Type = Workspace
tableFolder = gp.GetParameterAsText (3) #in a toolbox GUI, Type = Folder
tableName = gp.GetParameterAsText (4) #in a toolbox GUI, Type = String
tableView = tableFolder + "\\" + tableName
gp.Workspace = tempWorkspace
wsDesc = gp.Describe(tempWorkspace)
wsType = wsDesc.WorkspaceType
...&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The parameters are added correctly to the array, but I get an unspecified error when I try to execute the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank-you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 19:18:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63663#M2255</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2010-11-05T19:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Running python script from VBA code</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63664#M2256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Lorna;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why would you use VBA to program a GUI, when an interface that looks like the image I've attached can easily be built within the toolbox? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 23:34:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63664#M2256</guid>
      <dc:creator>JeffLee</dc:creator>
      <dc:date>2010-11-05T23:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Running python script from VBA code</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63665#M2257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a couple of reasons.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. The code doesn't just provide a GUI for the parameters, it also uses that information to select which script to run.&amp;nbsp; I could just use a separate script tool for each task, but I want to make it intuitive for other people to use when I'm gone.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. I didn't think that you could include a combo box in the toolbox GUI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. I'm curious to know how it's done.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Nov 2010 16:24:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63665#M2257</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2010-11-08T16:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Running python script from VBA code</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63666#M2258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Check these links for the how's and why's of script tools:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=An_overview_of_creating_script_tools"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=An_overview_of_creating_script_tools&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://resources.esri.com/geoprocessing/index.cfm?fa=codeGalleryDetails&amp;amp;scriptID=16491"&gt;http://resources.esri.com/geoprocessing/index.cfm?fa=codeGalleryDetails&amp;amp;scriptID=16491&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would just educate your users better on knowing which tool to run. If you really needed to you could probably still use a VBA or .NET GUI to open each tool's dialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For combo boxes, you can use a string parameter with a fixed value list, which would allow users to pick a value from a dropdown.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Nov 2010 16:59:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63666#M2258</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2010-11-08T16:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running python script from VBA code</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63667#M2259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Lorna please read below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Jeff,&lt;BR /&gt;There are a couple of reasons.&lt;BR /&gt;1. The code doesn't just provide a GUI for the parameters, it also uses that information to select which script to run.&amp;nbsp; I could just use a separate script tool for each task, but I want to make it intuitive for other people to use when I'm gone.&lt;BR /&gt;&lt;BR /&gt;Lorna;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Running a python script from VBA can be a PITA.&amp;nbsp; If you have several scripts that you need to run, one option could be to put all the code in one big script and have a drop down menu to pick which part of the script to run.&amp;nbsp; if you only do geoprocessing, I would try to stick to python.&amp;nbsp; However, if you need VBA for GIS operations that are not available in the toolbox, you may need to stick to VBA.&amp;nbsp; The thing however is that VBA will eventually go the way of the dodo as version 10 is the last version with VBA support.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;2. I didn't think that you could include a combo box in the toolbox GUI.&lt;BR /&gt;3. I'm curious to know how it's done.&lt;BR /&gt;&lt;BR /&gt;Really easy see attached word document and toolbox in zipped file.&amp;nbsp;&amp;nbsp; The demo toolbox can be imported into arcgis.&amp;nbsp; Please forgive my bad grammar and layout in the attached document.&amp;nbsp;&amp;nbsp; to Conclude, you can do a lot with python and it's only gonna get better with time.&amp;nbsp; I hope this helps.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 02:32:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/running-python-script-from-vba-code/m-p/63667#M2259</guid>
      <dc:creator>JeffLee</dc:creator>
      <dc:date>2010-11-09T02:32:11Z</dc:date>
    </item>
  </channel>
</rss>

