Is This Content Helpful?
How can we make this better? Please provide as much detail as possible.
Note: This article pertains to ArcGIS versions 8.x and 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
This article shows how to create a new UIButtonControl that zooms in a specified amount.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
'Set the Zoom factor Dim zoomAmount As Integer zoomAmount = 2 Dim pMxApp As IMxApplication Dim pMxDoc As IMxDocument Dim pDisp As IScreenDisplay Dim pPoint As IPoint Dim pCenterPoint As IPoint 'Get the display Set pMxApp = Application Set pDisp = pMxApp.Display Set pMxDoc = Document 'Get the current extent envelope (rectangle) 'and another envelope to change Dim pCurrentEnv As IEnvelope Dim pEnv As IEnvelope Set pCurrentEnv = pMxDoc.ActiveView.Extent.Envelope Set pEnv = pMxDoc.ActiveView.Extent.Envelope 'Set the height and width of the new 'envelope to half the original pEnv.Height = pCurrentEnv.Height / zoomAmount pEnv.Width = pCurrentEnv.Width / zoomAmount 'Get and set the center point of the new envelope 'equal to the center point of the existing envelope. Set pPoint = New Point Set pCenterPoint = New Point pCenterPoint.X = pCurrentEnv.LowerLeft.X + _ pCurrentEnv.Width / 2 pCenterPoint.Y = pCurrentEnv.LowerLeft.Y + _ pCurrentEnv.Height / 2 pEnv.CenterAt pCenterPoint 'Set the view extent to the new envelope 'and refresh the view pMxDoc.ActiveView.Extent = pEnv pMxDoc.ActiveView.Refresh