My map has about 40 bookmarks. I want to export each to an individual Illustrator file. I've tried to adapt code I saw elsewhere, but I'm a total python novice. Instead of getting 40 exported files, it's re-exporting the same file name over and over.

import arcpy.mapping
Folder = r"H:\My Documents\Maps" 
mxd = arcpy.mapping.MapDocument("CURRENT")  
df= arcpy.mapping.ListDataFrames(mxd, "Layers") [0]  

for bkmk in arcpy.mapping.ListBookmarks(mxd, "", data_frame=df):  
    df.extent = bkmk.extent  
    dfname = bkmk.name  
    arcpy.mapping.ExportToAI(mxd, Folder + "\map" + dfname + ".ai", resolution=300)

Edit November 15, 2017: this code now seems to work, at least once. I'm not sure what problem I had going before; maybe it was related to the output folder. I have found, however, that if something breaks in the script (e.g., one time I had a backslash in a bookmark name) I can't rerun it even after fixing the issue. I have to restart my ArcMap session.

  • Perhaps convert them to polygons first, use as data driven pages and try to export.
    – FelixIP
    Commented Oct 11, 2017 at 4:19
  • @PolyGeo can direct you to code converting bookmarks to polygons. I use his.
    – FelixIP
    Commented Oct 11, 2017 at 4:21
  • Thanks @FelixIP. I know that's an alternative, but now that I have my bookmarks set I want to use them. I also want to learn why this isn't working for my own knowledge.
    – Nick Welch
    Commented Oct 11, 2017 at 4:32
  • I wonder what file name you've managed to produce? Use r"\map" anyway.
    – FelixIP
    Commented Oct 11, 2017 at 5:50

1 Answer 1


This is the code for a script tool I use for such tasks (exporting to PDF), it works just fine. Just adapt the script in order to produce an .ai file. (more information on how to set up a script tool can be found here)

There are a few downsides to this method however: you cannot easily switch layers on / off with this script (as mentioned in the comments, using DataDrivenPages is of advantage here); there are certain exporting problems with word / excel objects in your map layout (such as headers); labels can be troublesome for exporting like this; you should not run this tool in background mode, as there might be missing layers in your exported product.

Here is my code:

import arcpy

workspace = arcpy.GetParameterAsText(0)

arcpy.env.workspace = workspace
arcpy.env.scratchworkspace = workspace
arcpy.env.overwriteOutput = True

mxdPath = arcpy.GetParameterAsText(1) # arcpy.mapping.MapDocument("CURRENT")
prefix = u"{}".format(arcpy.GetParameterAsText(2))
postfix = u"{}".format(arcpy.GetParameterAsText(3))
desiredresolution = arcpy.GetParameter(4)

mxd = arcpy.mapping.MapDocument(mxdPath)
df = arcpy.mapping.ListDataFrames(mxd)[0]
bookmarkList = arcpy.mapping.ListBookmarks(mxd, data_frame=df)
arcpy.AddMessage("""{0} bookmarks found. Exporting PDFs...""".format(len(bookmarkList)))
mxd.activeView = "PAGE_LAYOUT"
i = 1
for bookmark in bookmarkList:
    df.extent = bookmark.extent
    outName = u"{0}".format(bookmark.name)
    outFile = u"{0}\{1}{2}{3}".format(workspace, prefix, outName, postfix)
    arcpy.mapping.ExportToPDF(mxd, outFile, "PAGE_LAYOUT", resolution = desiredresolution)
    arcpy.AddMessage("""Bookmark Nr. {0} exported...""".format(i))
    i += 1

Your Answer

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

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