Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In ArcMap 9.x how can I attach a python script to a button?

share|improve this question
What do you mean by a button? The easiest way to integrate a python script into ArcMap is through Toolbox. Is that okay? – fmark Jul 28 '10 at 0:10
no, not through a toolbox. that takes up too much screen real estate. – matt wilkie Jul 28 '10 at 14:18
arcmap 10 version of this question:… – matt wilkie Oct 4 '11 at 22:26
up vote 7 down vote accepted

This works in VBA to run a Python script. Just call the subroutine with a button.

Private Sub python_Click()
    Shell "C:\Python25\python.exe ""C:\"
End Sub

Hope this helps.

share|improve this answer
this is a good example of why this stack exchange platform works. I had an answer ready, but this one is simpler and cleaner. Thanks :) – matt wilkie Jul 28 '10 at 18:16
What about .net? Any code snippets? – George Jul 28 '10 at 19:04

As @fmark says, the easiest way to integrate a Python script into ArcMap is through a toolbox, which I'd recommend.

That said, if you really need to (eg, you need a nicer front end than the toolbox) you have two options:

  1. You can call the script as a command line argument from another program that is linked to the button - the easiest would be VBA.
  2. You can add the Python script to the toolbox, and call the custom toolbox from your button (VBA, VB.Net, C#.Net).

Still, I'd go with @fmark and just add the script to the toolbox given the choice.

share|improve this answer

The way to do it in C# would be like this using the ArcGIS template for a button.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace RunEditPython
    public class PythonEdited : ESRI.ArcGIS.Desktop.AddIns.Button

    public PythonEdited()

    protected override void OnClick()
    protected override void OnUpdate()
        Enabled = ArcMap.Application != null;


share|improve this answer
thanks! and welcome to GIS stack exchange. I hope you find your time here fruitful; you've certainly come bearing gifts, it's appreciated. – matt wilkie Apr 12 '11 at 17:37

Your Answer


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.