I am trying to export a chart from Excel to either the wmf or emf format.
The code works if you export to GIF but not with WMF as the filtername.
This works:
Chart.Export FileName:="current_sales.gif", FilterName:="GIF"
But
Chart.Export FileName:="current_sales.wmf", FilterName:="WMF"
fails giving the error:
Run-time error '1004': Application-defined or object-defined error
Powerpoint allows you to export to WMF. And I have "successfully" exported by copying the graph into Powerpoint and having Powerpoint export the image to WMF but there has to be an easier way - I hope.
I wonder if there may be a way of registering the WMF filter for Excel but I am unsure how to do this. Please help! Thanks.
Through this forum entry you can find the marvelous Stephen Bullen's Excel Page and download the PastePicture utility which shows how you can export to the WMF format.
It basically copies the chart, pastes it into the clipboard as a picture and saves its content into a WMF file in a few lines of code.
Funny this, this poster had the exact same problem on this forum here, Came across this interesting article at ExcelForum in relation to this.
Hope this is of help to you, Best regards, Tom.
This copy, save method worked for me, i put it into 3 sections (declarations, saves as EMF function, and the select/copy/function call section):
*I found this article detailing how to save to EMF then doctored it a bit to use the an ActiveChart instead of a arbitrary selection.
First off a couple declarations:
This is the actual save as emf function (the use of CopyEnhMetaFileA and DeleteEnhMetaFile are explained in the article):
Then the select, copy, and function call section:
Andy has answered this in detail Here.