I'm relatively new to GIS and looking to automate a project. I have my 'base map' created in ArcGIS, but now need to create several hundred more so looking for an automated method to accomplish this. I have a desktop version of ArcGIS 9.3. I'm currently using VB, Python isn't installed and will require going through IT and business case...

Things I need to figure out: 1. Select the Area of Interest (Polygon) 2. Zoom to the select area 3. Change title 4. Change legend to add some details (can be either the layer name or the description for the layer). 5. Export to PDF.

I have figured out #1, but stuck on #2, because although it does zoom to the polygon of interest it isn't choosing the same zoom I'd get if I manually clicked "Zoom to Selected Features".

Any suggestions on things I should look into or resources?

Thanks, Reese

3 Answers 3


If you are using the ArcObjects/VBA macro in ArcMap approach you can do the following (sorry some of the code examples are in .NET, but the idea is the same):

for number 2 use ArcMap Command Zoom to Selected Features:

 Dim pUID As New UID
 Dim pCmdItem As ICommandItem
 Dim pApp As IApplication
 ' Use the GUID of the Save command
 pUID.Value = "esriArcMapUI.ZoomToSelectedCommand"
 pUID.SubType = 3
 pCmdItem = pApp.Document.CommandBars.Find(pUID)

for number 3:

            Dim pLayoutS As IPageLayout2
            Dim pGCS As IGraphicsContainer
            Dim pTS As ITextElement
            Dim pAvS As IActiveView
            Dim pElPropS As IElementProperties
            Dim pElementS As IElement

            pLayoutS = CType(m_pMxDoc2.PageLayout, IPageLayout2)
            pGCS = CType(pLayoutS, IGraphicsContainer)
            pAvS = CType(pLayoutS, IActiveView)

            pElementS = pGCS.Next

            'Get existing date graphic and update time and date.
            Do Until pElementS Is Nothing
                pElPropS = CType(pElementS, IElementProperties)
                If pElPropS.Name = "Current Text" Then
                    pTS = CType(pElementS, ITextElement)
                    pTS.Text = "New Text"
                    pAvS.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElementS, Nothing)
                End If
                pElementS = pGCS.Next

for number 4, can you turn off the layers that you do not want to show in the legend:

            Dim pMap As IMap = Nothing
            Dim pLayer As ILayer
            Dim pGroupLayer As IGroupLayer = Nothing
            Dim i As Integer

            Dim pGrphcon As IGraphicsContainer = Nothing
            Dim pElem As IElement = Nothing
            Dim pTxtElem As ITextElement = Nothing
            'Dim pElPropS As IElementProperties
            Dim pAvS As IActiveView = Nothing
            Dim pPageLayout As IPageLayout

            pPageLayout = m_pMxDoc2.PageLayout
            m_pMxDoc2.ActiveView = pPageLayout

            pMap = m_pMxDoc2.FocusMap

            Dim pContentsView As IContentsView
            pContentsView = m_pMxDoc2.CurrentContentsView

            For i = 0 To pMap.LayerCount - 1
                If pMap.Layer(i).Name = "My Layer to turn off" Then
                    pLayer = pMap.Layer(i)
                    If TypeOf pLayer Is IGroupLayer Then
                        pGroupLayer = pLayer
                        pContentsView.SelectedItem = pLayer
                        'Turn off layer here in TOC
                        pGroupLayer.Visible = False

                        strLayerName = pLayer.Name


                    End If
                End If
            Next i

for number 5:

See this example - Export Active View to JPEG


I use DDP Then I set up several fields in my data.

page name, page number, rotation, ref_scale, scale, page_on.

I use these to manage the zoom scale and reference scale on each page. Most of them go in the data driven pages dialog. Page_on I use to limit the objects (by query) that will generate pages.
BTW: You can use line features as the index layer.
Then utilize the scale on the extent tab to get the zoom you are talking about.
Then a template layout with Just about anythingyou can think of as marginalia can be used by setting dynamic text, enable match/don't match in the page definition, dynamic legend. and more.

data driven pages

Then when you print you use the all pages option to either export to pdf or print.

Export pages

  • Um, aren't Data Driven Pages only available in ArcGIS 10.x? I remember having to do a lot of VB programming to accomplish something similar in 9.x.
    – Baltok
    Dec 5, 2012 at 17:48
  • 1
    9.x it was called dsmapbook. you didn't have to do any programming but did have to load the dll. 10.0 it is called data driven pages. 10.1 ddp is VERY usable. OP did not indicate a version of arcgis.
    – Brad Nesom
    Dec 5, 2012 at 20:06
  • Thanks Brad! I don't have install rights though, so it doesn't seem to work. Is there a way to add all the code to a project?
    – Reeza
    Dec 5, 2012 at 21:19
  • 1
    You cannot change #4 with dsmapbook, you'll have to use ArcObjects for that.
    – artwork21
    Dec 6, 2012 at 2:17

you should use Arcobject and programming using C#, VB.net and other programming language that support Arcobject.

  • Your answer is valid, however not very clear on what objects to use and how to run the macro.
    – artwork21
    Dec 6, 2012 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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