T
Todd Garrison
Hello,
I've successfully been exporting a series of dynamically generated charts
from Excel to GIF (I'm programming in VSTO) using code like:
Me.Application.ActiveChart.Export("C:\mygraph.gif","GIF")
I now need to export these same charts to EMF or WMF so that they can be
imported into Word and printed in high quality documents.
I've been trying the following, but with no luck:
Me.Application.ActiveChart.CopyPicture(Excel.XlPictureAppearance.xlScreen,
Excel.XlCopyPictureFormat.xlPicture, Excel.XlPictureAppearance.xlScreen)
Dim d As IDataObject = Clipboard.GetDataObject()
If (d.GetDataPresent(DataFormats.EnhancedMetafile)) Then
Dim pictBox1 As Image
pictBox1 = d.GetData(DataFormats.EnhancedMetafile)
pictBox1.Save("C:\mygraph.emf")
End If
Which dies with the error:
Object reference not set to an instance of an object.
The more I read, the more I feel like I'm nowhere close to the solution yet.
Can anyone point me in the right direction?
Any help appreciated.
Thanks
Todd
I've successfully been exporting a series of dynamically generated charts
from Excel to GIF (I'm programming in VSTO) using code like:
Me.Application.ActiveChart.Export("C:\mygraph.gif","GIF")
I now need to export these same charts to EMF or WMF so that they can be
imported into Word and printed in high quality documents.
I've been trying the following, but with no luck:
Me.Application.ActiveChart.CopyPicture(Excel.XlPictureAppearance.xlScreen,
Excel.XlCopyPictureFormat.xlPicture, Excel.XlPictureAppearance.xlScreen)
Dim d As IDataObject = Clipboard.GetDataObject()
If (d.GetDataPresent(DataFormats.EnhancedMetafile)) Then
Dim pictBox1 As Image
pictBox1 = d.GetData(DataFormats.EnhancedMetafile)
pictBox1.Save("C:\mygraph.emf")
End If
Which dies with the error:
Object reference not set to an instance of an object.
The more I read, the more I feel like I'm nowhere close to the solution yet.
Can anyone point me in the right direction?
Any help appreciated.
Thanks
Todd