Microsoft Office Tutorials and References
In Depth Information
21.16.3 PrintOut Method
The Export method exports a chart in a graphic format. The syntax is:
ChartObject .Export( FileName , FilterName , Interactive )
Here FileName is the name of the graphic file to create. FilterName is the name of the graphic
filter as it appears in the registry. Microsoft does not say where in the registry, but it seems likely
to be the key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Shared Tools\Graphics
Filters\Export
The Interactive parameter can be set to True to display the dialog box that contains
filterspecific options. If this argument is False (the default), Excel uses the default values for the filter.
To illustrate, the following code creates three graphic files from the active chart:
ActiveChart.Export "d:\excel\test.png", "PNG"
ActiveChart.Export "d:\excel\test.jpg", "JPEG"
ActiveChart.Export "d:\excel\test.gif", "GIF"
Note that in these cases, setting Interactive to True seems to have no effect. Note also that
any file of the name FileName will be overwritten without warning.
21.16.3 PrintOut Method
The PrintOut method prints the chart. This method applies to a variety of other objects, such as
Charts, Worksheet(s), Workbook(s), and the Range object. The syntax is:
ChartObject .PrintOut( from , To , Copies , Preview , _
ActivePrinter , PrintToFile , Collate )
Note that all of the parameters to this method are optional.
The From parameter specifies the page number of the first page to print, and the To parameter
specifies the last page to print. If omitted, the entire object (range, worksheet, etc.) is printed.
The Copies parameter specifies the number of copies to print. The default is 1 .
Set Preview to True to invoke print preview rather than printing immediately. The default is
False .
ActivePrinter sets the name of the active printer. On the other hand, setting PrintToFile
to True causes Excel to print to a file. Excel will prompt the user for the name of the output file.
(Unfortunately, there is no way to specify the name of the output file in code.)
The Collate parameter should be set to True to collate multiple copies.
21.17 Example: Scrolling Through Chart Types
There are a total of 73 distinct chart types. This is too many to easily look at examples of each
type by hand. However, a bit of coding can produce a simple application that scrolls through the
 
Search JabSto ::




Custom Search