This sample takes the current active view and exports it to a JPEG file.
[VBA]
The code samples in this section show the fundamentals of programming with ArcObjects. A careful reading of them gives you all the important concepts you need for developing with ArcObjects, as well as an introduction to the most important ArcObjects components.
The code can be typed or copied into the VBA environment in ArcMap or ArcCatalog, after which you can follow through with the VBA debugger.
How to use
- Add the code to the Click event of a UIButtonControl in ArcMap.
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim lScrRes As Long
lScrRes = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.Resolution
Dim pExporter As IExporter
Set pExporter = New JpegExporter
pExporter.ExportFileName = "C:\Export.jpg"
pExporter.Resolution = lScrRes
Dim deviceRECT As tagRECT
deviceRECT = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.DeviceFrame
Dim pDriverBounds As IEnvelope
Set pDriverBounds = New Envelope
pDriverBounds.PutCoords deviceRECT.Left, deviceRECT.bottom, deviceRECT.Right, deviceRECT.Top
pExporter.PixelBounds = pDriverBounds
Dim pCancel As ITrackCancel
Set pCancel = New CancelTracker
pMxDoc.ActiveView.Output pExporter.StartExporting, lScrRes, deviceRECT, pMxDoc.ActiveView.Extent, pCancel
pExporter.FinishExporting