AnsweredAssumed Answered

esriExtentBounds clears pMapFrame.MapBounds ?

Question asked by acangi on Sep 23, 2013
Latest reply on Jan 28, 2014 by sachin.kanaujia.gis

I have a code that works in Arcgis 9.3 and I'm supposed to make it work in Arcgis 10.0. I'm new to Arcgis programming and to VBA, no answer will be too basic for me :)

The code is :
Set pElement = Nothing
Set pElement = pContainer.Next
Do While Not pElement Is Nothing
  If pElement.Name = "Topo10" Then
    Dim pMapFrame As IMapFrame
    Set pMapFrame = pElement
    Exit Do
  End If
  Set pElement = pContainer.Next
If pMapFrame Is Nothing Then
  MsgBox "BUG with mapFrame"
  Exit Sub
End If

Dim pMap As IMap
Set pMap = pMapFrame.Map
Set pMap.SpatialReference = OpenLambertSpatialRef
pMap.AddLayer OpenLayerFile(TOP10PATH, "TOP10.lyr")

pMapFrame.ExtentType = esriExtentBounds        'clears pMapFrame.MapBounds
pMapFrame.MapScale = 10000
Dim pEnvelope As IEnvelope
Set pEnvelope = pMapFrame.MapBounds

The problem comes at the line in bold (pMapFrame.ExtentType = esriExtentBounds). After this line, pMapFrame.MapBounds becomes Nothing, so I can't copy it in pEnvelope (this worked in 9.3). If I remove the line in bold then it works, but the result isn't at the good coordinates.

Any idea why it happens ? Or do you know another way I could do this ?

Any answer is appreciated,