HOW TO
This article shows how to make a locator rectangle in a data frame showing the visible extent of another data frame.
Note:
Code in ThisDocument module will only run in the current map document. If you want to store the code in all your map documents, open the Normal.mxt ThisDocument code module.
Code:
Sub GetRect()
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pPageLayout As IPageLayout
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Set pPageLayout = pDoc.PageLayout
Dim pGC As IGraphicsContainer
Dim pStatesFrame As IMapFrame
Dim pCitiesFrame As IMapFrame
Dim pElem As IElement
' Get the Map Frames
Set pGC = pPageLayout
Set pStatesFrame = pGC.FindFrame(pDoc.Maps.Item(0))
Set pCitiesFrame = pGC.FindFrame(pDoc.Maps.Item(1))
' Create the New Locator Rectangle
' The new rectangle shows the extent of the cities layer
' on the states layer
Dim pLocRec As ILocatorRectangle
Set pLocRec = New LocatorRectangle
Set pLocRec.MapFrame = pCitiesFrame
' Add it to the States Data Frame
pStatesFrame.AddLocatorRectangle pLocRec
Debug.Print pStatesFrame.LocatorRectangleCount
' Refresh the view
pDoc.ActiveView.Refresh
End Sub
Article ID:000004955
Get help from ArcGIS experts
Download the Esri Support App