Select to view content in your preferred language

Activating Data Frame

734
2
12-11-2011 10:14 PM
nassar1nassar2
New Contributor
I wrote two codes for activating the second data frame in arcmap,the first one works on but the second doesn't and I get the error "object doesn't support this action" Iwant to understand why?

1st code:
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument

Dim pMaps As IMaps
Set pMaps = pMxDoc.Maps

Dim pMap As IMap
Set pMap = pMaps.Item(1)

Set pMxDoc.Activeview=pMap

2nd Code:

Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument

Dim pMaps As IMaps
Set pMaps = pMxDoc.Maps

Dim pMap As IMap
Set pMap = pMaps.Item(1)

Dim pActiveView As IActiveView
Set pActiveView = pMap
Set pActiveview.FocusMap=pMap
0 Kudos
2 Replies
JimBarry
Esri Regular Contributor
moving to ArcObjects forum  -jb
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
The 2nd code fails at Set pActiveview.FocusMap=pMap . You can set IActiveView.FocusMap property, only if current active view is in the page layout mode.

Here is the code I would use:
Dim pActiveView As IActiveView
Set pActiveView = pMxDoc.ActiveView
If TypeOf pActiveView Is IPageLayout Then
   Set pActiveView.FocusMap = pMap
ElseIf TypeOf pActiveView Is IMap Then
   Set pMxDoc.ActiveView = pMap
End If
0 Kudos