[Excel 2003] Exporting Diagram as Bitmap with VBA

J

Jens Nixdorf

Hi all,

i have to export Diagrams out of Excel 2003 during an automatic analysis,
and i have some trouble with it. If i use the standard way (in my
understanding) with VBA like this:

Dim Dia As Chart
Set Dia = Worksheets("Tabelle1").ChartObjects(1).Chart
Dia.Export Filename:="Test.gif", FilterName:="GIF"
Set Dia = Nothing

i get always a "runtime error 1004: method 'export' for object '_Chart'
failed" (this is translated from german to english, so maybe the sentence
is not real the same as in your version of excel).

I tried some different formattings for the code above, with complete paths
in a line or with the paths in variables, some other export-filters like
JPG and so on, but always without success.

At the moment i'm using a workaround as exporting the table with the
embedded diagram as a web-page, and there _IS_ a bitmap (GIF) inside, which
i can use then. But because the amount of data sometimes is huge and the
analysis will generate sometimes more than 30 tables, this workaround is
consuming much ressources withoud need.

Thanks for any hint,

regards, Jens
 
P

Peter T

Hi Jens,

Your code is pretty much the same as the Help example so it should work.
Some filters need to be installed in the Office setup but according to mine
Gif and some others do not need to be specifically installed for Excel.

According to help -
"FilterName Optional Variant. The language-independent name of the graphic
filter as it appears in the registry."

I would have thought gif type would be the same in all languages but perhaps
not in yours. Try with .gif as the extension and FilterName:="", ie an empty
string which surprisingly seems to work for me.

Regards,
Peter T
 
J

Jens Nixdorf

Peter T schrubte am Dienstag, 16. Januar 2007 21:43:
I would have thought gif type would be the same in all languages but
perhaps not in yours. Try with .gif as the extension and FilterName:="",
ie an empty string which surprisingly seems to work for me.

Thank you very much, this was the solution for a problem which was a pain in
my neck for several weeks. In the registry the FilterName is written
as "GIF", so i used it in my code this way. Why it doesnt work, who knows?
Maybe a bug in non-english-language versions of office...

regards, Jens
 

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

Top