This sample takes the currently active view and prints the file to a PostScript printer.
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 pPrinter As IPrinter
Set pPrinter = New PsPrinter
Dim pMxApp As IMxApplication
Set pMxApp = ThisDocument.Parent
Set pPrinter.Paper = pMxApp.Paper
pPrinter.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
Dim pCancel As ITrackCancel
Set pCancel = New CancelTracker
pMxDoc.ActiveView.Output pPrinter.StartPrinting(pDriverBounds, 0), lScrRes, deviceRECT, pMxDoc.ActiveView.Extent, pCancel
pPrinter.FinishPrinting