Programming pasting charts to work problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am atomating report production using Excel and word. The basic operation is
ok I use bookmarks in word to position tables an charts pasted from Excel.
My problem is that the report designers have specified round corners to the
chart borders. This is no problem to set up in Excel and manually pasting the
chart to Word works fine. However doing it by programming turns the round
corners to square ones! Why?
I use the code below to paste the charts - My thanks for any suggestions

With rbmReport
..Select
xlWSheet.ChartObjects(cArray(iLoop)).Copy
.PasteSpecial _
Link:=False, _
Placement:=wdInLine, _
DataType:=wdPasteEnhancedMetafile
End With
 
Dean,

You could try using CopyPicture. It's also more memory efficient since it is
not embedding the underlying chart data in the word document. However, if
you do it repeatedly you'll eventually see a bug that the method fails so
add some error handing and a retry routine.

Sub Macro1()
Dim oWord As Word.Application
'set a reference to Word object library for the project
'chart 1 has round corners
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlPrinter, Size:=xlScreen, Format:= _
xlPicture
Set oWord = GetObject(, "Word.Application")
With oWord
'this gives round corners in Word 10
.Documents.Add
.Selection.Paste
End With
End Sub

Robin Hammond
www.enhanceddatasystems.com
 
Thank you Robin I shall try this method. I note your caution about the bug
and I am doing it repeatedly for different graphs so It will probably apply.

I assume the problem with the method I was using is a bug.
 

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

Back
Top