12

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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 2, 2010 at 22:37

2 Answers 2

6

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
answered Sep 17, 2010 at 23:12
3
answered Sep 28, 2010 at 19:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.