Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I believe that in Arc9.3, commands could be created using VBA scripts. To add a custom command, you would navigate to Customize > Toolbars > Customize... and click UIControls. However, UIControls is not there in version 10.

I am creating two separate scripts for a map book project. One script will save the layout settings to a table, and the other will update the layout with settings from the same table. I want both of these scripts to be commands assigned to buttons in a toolbar. I created them as script tools, but whenever I click on them, they run the script as a geoprocessing tool. It brings up a progress window, and it takes about 10 times longer to execute than if I had run the code in the Python command line window. I don't want the progress window or the much longer execution time. How can I make it so that the script isn't considered a "tool" and is instead a command similar to the Save button?

share|improve this question
add comment

2 Answers 2

Within an Excel VBA macro, the following calls a Python script called test.py:

Sub test()

rsp = Shell(Environ$("COMSPEC") & " /c C:/test.py", vbNormalFocus)

End Sub

(Original source here) I've forgotten how to run an ArcGIS VBA module, but perhaps a similar line would work to call your python script.


Another strategy that might work could be to compile your python script to an executable (.exe) or batch file (.bat) and call it then.


I just saw another answer on gis.se that is more elegant:

Private Sub python_Click()
    Shell "C:\Python25\python.exe ""C:\rowcount.py"
End Sub
share|improve this answer
add comment

I'm a complete GIS newb, but I came across this in the documentation:

You can make your script tools run faster by running them in process. This topic describes in-process execution.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.