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

446
2
08-29-2012 02:16 PM
MarlonAmaya1
New Contributor
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
0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor
Don't know what the problem is but as you are using vba why not put in a "doevents" call?
0 Kudos
MarlonAmaya1
New Contributor
I usually only use doevents in loops.  Not sure how that would help here.
0 Kudos