Attribute VB_Name = "MakeActivateDataFrame" 'This code makes the selected DataFrame (aka Map) the Active data frame 'Essentially it does the same thing as right clicking on the Data Frame and choosing 'Activate Public Sub MakeActive() Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument 'RETURN WHETHER THE toc IS IN SOURCE OR DISPLAY MODE TAB Dim pContentsView As IContentsView Set pContentsView = pMxDoc.CurrentContentsView 'RETURNS SELECTED THING (HOPEFULLY DATAFRAME - IMAP) INSIDE OF toc Dim pMap As IMap If Not TypeOf pContentsView.SelectedItem Is IMap Then MsgBox "Please Select a DataFrame" Exit Sub Else Set pMap = pContentsView.SelectedItem End If 'returns whether the map is in pagelayoutview or dataview Dim pActiveView As IActiveView Set pActiveView = pMxDoc.ActivatedView 'Makes the selected data frame the Active dataframe If TypeOf pActiveView Is IPageLayout Then Set pMxDoc.ActiveView.FocusMap = pMap Else Set pMxDoc.ActiveView = pMap End If End Sub