This sample zooms the focus map to the extent of a layer. For simplicity sake, the first layer in the map is used.
How to use
- Paste the code into VBA.
- Modify the code to get the desired layer.
- Execute the routine.
Public Sub ZoomToLayer()
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pActiveView As IActiveView
Set pMxDoc = Application.Document
Set pMap = pMxDoc.FocusMap
Set pActiveView = pMap
If pMap.Layer(0) Is Nothing Then Exit Sub
pActiveView.Extent = pMap.Layer(0).AreaOfInterest
pActiveView.Refresh
End Sub