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.

Is there a way to change from layout view to data view using python? I would prefer to do it using arcpy.

share|improve this question
Just curious, what's the use case for wanting to do this? –  Derek Swingley Sep 28 '10 at 22:43
I originally wanted to do this because in ArcMap 10 the buttons to switch to layout or data view disappear sometimes. I thought I could simply change it using Python, but I still haven't been able to. It's not a solution to the problem, but I was more interested in learning how to do this in python anyway. –  Tanner Sep 30 '10 at 3:36

2 Answers 2

up vote 4 down vote accepted
mxd = arcpy.mapping.MapDocument('CURRENT')
mxd.activeView = "my_data_frame_name"
share|improve this answer
Forget my last comment. It did work! Thanks a lot! –  Tanner Nov 15 '10 at 4:39

To go the other way is as easy as arcpy.mapping.MapDocument("current").activeView = "PAGE_LAYOUT".

share|improve this answer
Thank you. I see the mention of "PAGE_LAYOUT" now in the online documentation. I appreciate you pointing this out. It's the last thing I needed for porting a 60-page mapping tool written in VBA and ArcObjects to a 10-page tool written with Python and arcpy. Plus, I can also take advantage of data driven pages. Thanks again! –  user1853 Feb 3 '11 at 13:39

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.