eexton

8.3 to 10.1  VBA Pan function not working (pEnv.CenterAt)

Discussion created by eexton on Aug 29, 2012
Latest reply on Sep 19, 2012 by eexton
I have an automated program that pans to a predefined point on a map, makes adjustments like scale, and exports the map.

Under 8.3, it worked flawlessly.  Under 10.1, it works for a while then gets "stuck" and all exports after that are of the same map area.  I verify that it is being passed new coordinates, but if I check before and after the function the map has not moved.  There are also no errors reported.

Its frustrating because it is intermittent.  Sometimes it stops working after 5, sometimes 20, sometimes hundreds. And whenever it stops, all calls after that result in the same image being exported because it never moves.

1) Any ideas of how to fix it?
2) Any way to test it to at least catch that it didnt move and throw an error so bad images are not saved?

Thanks.


Private Sub Pan(dX As Double, dY As Double)
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    
    Dim pav As IActiveView
    Set pav = pMxDoc.FocusMap
    
    
    Dim pEnv As IEnvelope
    Set pEnv = pav.ScreenDisplay.DisplayTransformation.FittedBounds.Envelope
    
    Dim pPoint As esriGeometry.IPoint
    Set pPoint = New esriGeometry.Point
    pPoint.PutCoords dX, dY
    pEnv.CenterAt pPoint
    pav.ScreenDisplay.DisplayTransformation.VisibleBounds = pEnv
    pav.Refresh
    
    Set pav = Nothing
    Set pEnv = Nothing
    Set pMxDoc = Nothing
   
End Sub

Outcomes