The following code shows you how to activate the last data frame (map) in the map document.
How to use
- Open a map document with more than one dataframe.
- Copy-paste this procedure into ArcMap's VB Editor.
- Run the procedure.
Public Sub ActiveDataFrame()
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pMaps As IMaps
Set pMaps = pMxDoc.Maps
Dim pMap As IMap
Set pMap = pMaps.Item(pMaps.Count - 1)
Dim pActiveView As IActiveView
Set pActiveView = pMxDoc.ActiveView
If TypeOf pActiveView Is IPageLayout Then
Set pMxDoc.ActiveView.FocusMap = pMap
Else
Set pMxDoc.ActiveView = pMap
End If
End Sub