Activating Data Frame

307
1
12-11-2011 02:10 AM
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
1 Reply
NeilClemmons
Regular Contributor III
In the first example, you're setting the document's active view to the map you got from the document's maps collection.  In other words, you're changing the map referenced by the document from one map (or page layout) to another.  The second example doesn't work because it doesn't make any logical sense.  You're getting the map in the same way but instead of using it to set the document's active view you're QI'ing from IMap to IActiveView and changing the focus map reference.  The IActiveView reference you're working with is the map you got from the maps collection.  Changing any of its properties is not going to affect the document because there is no relationship between the document and that map.  You get the error because the action you're taking isn't implemented.  In this scenario the IActiveView reference is a map.  Changing the focus map of a map to another map doesn't make sense.
0 Kudos