You may have noticed that the listings for the print preview window code are from the Charter application, which I first discussed in Chapter 6. I thought it would be nice if I added the ability to send both the chart and the grid to the printer. Listing 9.17 shows how easy it is to print a report using the common routines. First, I select the entire chart and copy it to the clipboard. Then I simply use the WritePicture routine to either display the picture in the preview window or print it on the physical printer, depending on the parameter passed to this routine.
Listing 9.17: PrintChart Routine in Charter
Private Sub PrintChart(o As Object)
MSChart1.SelectPart VtChPartTypeChart, 0, 0, 0, 0
MSChart1.EditCopy
WritePicture Clipboard.GetData, 1440, 1440, o
WriteEndDoc o
End Sub