Exporting graphs causes unwanted resizement!

E

erooijackers

I have written a macro that exports 44 graphs to a certain directory
under unique names. The problem hereby is that every time i use this
macro, the graphs turn smaller and smaller. When the macro is used
about 5 times, the graphs (piecharts) are about 40% of its original
size i created them.

The resizing affects not the outer graph box (title, graph, labels
etc.), but only the inner graph (only piechart display) box.


VBA code used.
Sub ExportAllCharts()

Sheets("Graphs").Select
ActiveSheet.ChartObjects("Grafiek 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.Export Filename:="W:\GEBOUW\DATAHVD\Beheer\Beheer Energie
\-- Website updating--\Energy
section\All Graphs\2006 PieChart Electricity DAF Hi.jpg", _
FilterName:="jpeg"

ActiveSheet.ChartObjects("Grafiek 12").Activate
ActiveChart.ChartArea.Select
ActiveChart.Export Filename:="W:\GEBOUW\DATAHVD\Beheer\Beheer Energie
\-- Website updating--\Energy
section\All Graphs\2006 PieChart Gas DAF Hi.JPG", _
FilterName:="jpeg"

AND THE SAME FOR ALL OTHER 42 GRAPHS :)

Sheets("Macro blad").Select
Range("E19").Select
ActiveWorkbook.Save
End VBA code example

Does anyone have a solution?

(NOTE: i am a beginning VBA user)
 
J

Jon Peltier

I don't know about the resizing. Sometimes it may be due to selecting and
deselecting the chart. This code prevents the gratuitous selection of
objects, which will make the code run more quickly and make the screen
remain static without flashing, and it may help with the resizing:

Sheets("Graphs").ChartObjects("Grafiek 2").Chart.Export _
Filename:=sLongString, FilterName:="jpeg"

Also, charts usually look better exported using the GIF or PNG filters. JPEG
was designed for photographic images with gradual color transitions, not for
line art.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top