My Blog List

Friday, September 2, 2011

Exporting image

I was thinking for some reports it might be nice to include a map image.  Here's a little VBA code to do that.  I'd like to see if I can get this to work in the context of an HTML report (e.g. Brook's MM Report tools)


Private Sub export()
    Dim pexp As IExport
    Set pexp = New ExportJPEG
    pexp.ExportFileName = "c:\temp\test.jpg"
    pexp.Resolution = 96
    Dim x As tagRECT
    Dim mxDoc As IMxDocument
    Set mxDoc = ThisDocument
    Dim av As IActiveView
    Set av = mxDoc.ActiveView
    x = av.ExportFrame
    Dim env As IEnvelope
    Set env = New Envelope
    env.PutCoords x.Left, x.Top, x.Right, x.bottom
    pexp.PixelBounds = env
    Dim hdc As Long
    hdc = pexp.StartExporting
    av.Output hdc, pexp.Resolution, x, Nothing, Nothing
    pexp.FinishExporting
    pexp.Cleanup
End Sub

No comments:

Post a Comment