Select to view content in your preferred language

newbie question

1008
2
06-10-2011 04:49 AM
LobkeDeblaere
Occasional Contributor
We're currently using Arcgis 10 and we use some vba code but in the next version vba won't be supported anymore so I'm looking for a python solution.

Our vba code works like this:  The user selects a polygon then presses a button.  The code then selects all polygons from all the other layers that intersect the selected polygon.  Next an excel file is written with the data of the tables (a report)

Is this possible with Python?  And how do I start?
Tags (2)
0 Kudos
2 Replies
ChrisMathers
Deactivated User
It is possible! Now that you can make a script tool into a button on the toolbars its even better. You would have to tell the script which layer has the selection but thats the only step for the end user.

A selection is made,
script gets a list of the layers in the mxd,
select by location on each layer with selected layer as input,
read other layers (cursors honor selection) and write the values out to a CSV.

You can export straight to an excel file instead of a csv but you have to use win32com and that might be more complicated than is worth dealing with in this case.
0 Kudos
AndrewChapkowski
Esri Regular Contributor
You can try using openpyxl to write the excel 2007 documents: http://packages.python.org/openpyxl/

For pre-2007 documents try http://www.python-excel.org/
0 Kudos