HOW TO
The following VBA code calculates the center point of a data frame. The coordinates are in the map units of the data frame.
Note:
Code in ThisDocument code module will only run in the current map document. To store the code in all your map documents, open the Normal.mxt ThisDocument code module.
Code:
Sub ReturnCenter()
Dim pMxDoc As IMxDocument
Set pMxDoc = Application.Document
Dim pEnv As IEnvelope
Set pEnv = pMxDoc.ActivatedView.Extent
Dim pX As Double
Dim pY As Double
pX = (pEnv.XMax + pEnv.XMin) / 2
pY = (pEnv.YMax + pEnv.YMin) / 2
MsgBox pX & ", " & pY
End Sub
Article ID:000005582
Get help from ArcGIS experts
Download the Esri Support App