ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting graphs causes unwanted resizement! (https://www.excelbanter.com/excel-programming/391837-exporting-graphs-causes-unwanted-resizement.html)

[email protected]

Exporting graphs causes unwanted resizement!
 
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)


Jon Peltier

Exporting graphs causes unwanted resizement!
 
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
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


wrote in message
oups.com...
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)





All times are GMT +1. The time now is 10:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com