Excel Data -> Word Doc with Pie Chart

edro

Lifer
Apr 5, 2002
24,326
68
91
If I have an Excel spreadsheet with data that I want to be in a chart, but I also have a Word document that I want to add this data/chart to, can I do it on the fly?

If I have like 1000 of these indivualized sheets that I need to make, anyway to automate the process?

So I need to do a normal Excel to Word Merge, but I want it to convert some of the data into a pie chart.

Anyone have any idea what the hell I am talking about?

:D

Thanks!
 

WW

Golden Member
Jun 21, 2001
1,514
0
0
sure...quick example to start you out:

in excel, in the vb editor (tools > macro), make sure you have the microsoft word object library selected (go to Tools > references to check)...that will allow excel to control word

just as an example, in an excel worksheet,
in a1 to a4 have your data titles (a b c d for example)
in b1 to b4 have the values (10 20 30 40 for example)

then make this macro and run it. It will select the data range, make a pie chart, open word and paste the chart there
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Whoa thanks!

I also need to open a specific Word file and paste into it.

Are there any ways to specify where in Word you want to paste it? It just pastes it up top, not at the end of the file like I need.

This is an awesome start though, thank you very much!

Placement:=wdFloatOverText (I don't have MSDN installed, so I can't check the other variables :D)
 

WW

Golden Member
Jun 21, 2001
1,514
0
0
you could change the selection point in word first...then it would paste it where ever...

if you want the end of the document try:

WDApp.Selection.EndKey Unit:=wdStory

before the pastespecial line...

I didn't understand the MSDN statement, do you mean the online VBA help? if you hit F1 in the editor, it should come up, definately install that...

and remember, when you are 'controlling' word in excel, use the vba help in word to look up the syntax...the commands are just like you are programming in word

if you want to check out the msdn library online, just see here:

msdn link