Chart.export creates corrupt files randomly

triods358

New Member
Joined
Aug 27, 2010
Messages
1
Hi All,

I am developing a program using userforms to display various charts. I use the chart.export property to save and load chart pictures on userform images.
The program was developed under Windows XP using Excel 2007. I had absolutely no issue under this environment.

I bought a new computer lately running on Windows 7 with Excel 2010. Under this new environment the chart.export property fails randomly creating files with correct extensions but with no data (0 kb). Sometimes the export works properly and images are displayed appropriately, sometimes the export fails and I get the Run Time Error 481 - Invalid Picture.

I have 6 userfoms each displaying 2 to 3 charts. Only 2 of these 6 userforms are affected by the export failure. All others work appropriately.

Here is the code I use to export charts as pictures. This is exactly the same kind of code used for all userforms:

Code:

Set CurrentChart = Sheets("ANA_TECHNIQUE").ChartObjects("Chart 1").Chart
CurrentChart.ShowWindow = True
ANATECHCHART1 = ThisWorkbook.Path & "\TEMP\ANATECHCHART1.gif"
CurrentChart.Export Filename:=ANATECHCHART1, FilterName:="GIF"
AnaTechnique.Image1.Picture = LoadPicture(ANATECHCHART1)</pre>
I spent hours trying to understand this unstable behavior (registry, chart reference, etc) but got no luck.

Any help would be greatly appreciated. Thanks in advance!!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,882
Messages
6,127,535
Members
449,385
Latest member
KMGLarson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top