Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1
Default Save Chart as EMF File for Import into Word

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.XlPic tureAppearance.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
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Save Chart as EMF File for Import into Word

You could cut out the intermediate file, and simply copy the chart as a
picture in Excel and paste it into Word. I don't know the funky VSTO for it,
but in VBA it's pretty easy.

http://peltiertech.com/Excel/XL_PPT.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Todd Garrison" wrote in message
...
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.XlPic tureAppearance.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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I save a Word file as an ASCII format? Laurie Excel Discussion (Misc queries) 5 April 6th 06 01:31 AM
is it possible to save xls file to a word document like an attachm weit Excel Discussion (Misc queries) 2 February 22nd 06 06:57 PM
default save as file type does not work gregf Excel Discussion (Misc queries) 5 February 10th 06 07:50 PM
Reflecting info between an excel file and a word one or two excel file. Starriol Excel Worksheet Functions 0 November 3rd 05 01:49 PM
Reflecting info between an excel file and a word one or two excel file. Starriol Links and Linking in Excel 0 November 3rd 05 01:49 PM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"