Sub outputMapBlock()
If (MsgBox("是否开始导出图片,按指定范围?", vbYesNo) = vbNo) Then Exit Sub
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pActiveView As IActiveView
Set pActiveView = pMxDoc.ActiveView
Dim pExport As IExport
Set pExport = New ExportJPEG
pExport.ExportFileName = "C:\Test0.jpg"
pExport.Resolution = 300
Dim exportRECT As tagRECT
With exportRECT
.Left = 100
.Right = 600
.Top = 100
.bottom = 600
End With
'exportRECT 表示导出的图片绘制范围
Dim pPixelBoundsEnv As IEnvelope
Set pPixelBoundsEnv = New Envelope
pPixelBoundsEnv.PutCoords 605000, 100000, 606000, 101000 '指定导出的地形范围
Dim pE As IEnvelope
Set pE = New Envelope
pE.XMin = 0
pE.XMax = 700
pE.YMin = 0
pE.YMax = 700
pExport.PixelBounds = pE '图片的大小
Dim hDC As Long
hDC = pExport.StartExporting
pActiveView.Extent = pPixelBoundsEnv
pActiveView.Output hDC, pExport.Resolution, exportRECT, pPixelBoundsEnv, Nothing
pExport.FinishExporting
pExport.Cleanup
End Sub