esriExtentBounds clears pMapFrame.MapBounds ?

444
2
09-23-2013 02:04 AM
AlainCamus
New Contributor
Hello,

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
pContainer.Reset
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
Loop
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,

acangi
0 Kudos
2 Replies
swapnabhide
New Contributor
Hi acangi,

Can you send me the complete code you have? so that I can try to reproduce the issue and will get back to you with my findings.

Regards,
Swapna.
0 Kudos
SachinKanaujia
Occasional Contributor III
I believe what you want to accomplish is to set the map scale and then set the envelope from this MapBounds (at this scale)?

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

Shouldnt you be using esriExtentScale instead?

pMapFrame.ExtentType = esriExtentScale