How to print a MsChart in VB5?


The mschart.ocx control doesn't have any internal printing functions so we have to be tricky.
This code-snippet is originally taken from Microsoft themselves.

MSChart1.EditCopy
Form2.Picture1.Picture = Clipboard.GetData()
Printer.Print " "
Printer.PaintPicture Form2.Picture1.Picture, 0, 0
Printer.EndDoc
Unload Form2

You use a dummy form, in this case named 'Form2', with a dummy picturebox, in this case named 'Picture1'. The function prints the chart to the default printer.

As always, if you have any better suggestions, mail it to me!

The following suggestion came from Sampo.Peltonen@Essexems.fi

MSChart1.EditCopy
Printer.PaintPicture Clipboard.GetData(vbCFMetafile), 0, 0, Printer.Width,Printer.Height



Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 980828
<- The VB home
<- Daniels homepage