Copy two aligned graphs into Word

  • Thread starter Thread starter SiriS
  • Start date Start date
S

SiriS

Hello,
I have two graphs, one on top of the other, that I would like to cop
into a Word document just like they look in Excel.

I can copy each of the graphs separetly into Word, using the followin
VBA code

' Copy chart as a picture
Activechart.Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

' Paste chart at cursor position
With wordApp
.Selection.PasteSpecial Link:=False
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False
End With

But how to copy the two of them together just like they look in th
excel sheet? Any suggestions?

Thank you,
Sir

Attachment filename: two aligned graphs.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=56474
 
Hi,

Try grouping the charts before doing the copy picture.
This bit of code will group all the charts on the activesheet and then
copy the picture. You will need to modify if you have more than one set
of charts.

ActiveSheet.ChartObjects.Group
ActiveSheet.Shapes(1).CopyPicture
ActiveSheet.Shapes(1).Ungroup

By the way, do you really need to overlay your charts?

Cheers
Andy
 
Yes, this works! Thank you Andy Pope!!

I would really like to make just one chart of it, but I have no
managed. The problem is I need the secondary y axis to create th
vertical line, and I need another - a third ;o) - secondary y axis t
create the normal curve. I create the vertical line using Jon Peltier
excellent tip available a
http://peltiertech.com/Excel/Charts/AddLineVertSeries.html, but mayb
there are other ways of creating vertical lines, not using th
secondary axis?

But now that this works fine, I think I leave it like this for th
moment.

Thank you again!

Sir
 
Hi Siri -

Alternatively, you can copy a subset of the charts on the sheet:

activesheet.shapes.range(array("Chart 2","Chart 3")).select

and your paste in Word is fine.

Couldn't you use the secondary axes for both the lines and the normal
curve? What are the chart types for all of your series?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
Hi Jon,
yes, of course I could use the same secondary axis for the vertica
line and the normal curve! I see it now!

I have been so fixed with the fact that the second point for th
vertical line must have the same y value as maximum for the primary
axis, but of course it can have the same y maximum as the normalcurve
Since the points for the vertical line are just "fake" points.

Thank you!

Sir
 
Back
Top