Copy Excel Chart (2007) to Word (2007)

J

Josh T

I am programatically modifying an existing chart in Excel 2007 and need to
embed it into a document. The problem stems that we do not initially know
how many charts will be embedded, and they all differ in data points. Thus
because of the way they are linked (between Word and Excel) we cannot do the
following:

for each DataSet in All_DataSets
// create or modify data
Chart.Copy();
Document.Paste();


If we continue to modify any of the data points for a chart (and it has
already been once copied to the Word document) then all charts update
accordingly since they all refer to the same version. Each chart is
different in data but of the same type.


The only solution that I have figured out is to do a manual Copy (Ctrl + C)
and in Word do a Paste Special. Only then am I presented with the option to
paste it as a Microsoft Office Excel Chart Object, which solves my problem.
Doing a programattic Copy and a manual Paste Special does not give this
option.


How can we programatically copy the chart as an MS Office Excel Chart
Object so that we can continue to udpate the next data set without
modifying an already existing chart?


-- Josh
 
C

Cindy M.

Hi =?Utf-8?B?Sm9zaCBU?=,
The only solution that I have figured out is to do a manual Copy (Ctrl + C)
and in Word do a Paste Special. Only then am I presented with the option to
paste it as a Microsoft Office Excel Chart Object, which solves my problem.
Doing a programattic Copy and a manual Paste Special does not give this
option.
The Word object model also has the PasteSpecial method for the Range and
Selection objects. Have you tried recording the manual steps in a macro to get
the basic syntax? You should get something along the lines of .AddOLEObject for
the Shapes or InlineShapes collection...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

Josh T

Yes,

However I am receiving an error when implementing the code programatically
that "The specified data type is unavailable". I'm trying to paste it as a
wdPasteOLEObject.

P.S. I believe I'm having this discussion with you in another forum, only
because I wasn't sure which would receive the most activity. If you'd like
you can answer the question in just one place, and I will post the resolved
answer in the other to save you the time.

Thanks.
 

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