C# App Font issue with Excel Chart and into Word. RRS feed

  • Question

  • Hi 

    I have a C# Applicaiton which is copying a chart from Excel and "pasting" into Word.

    When pasting into Word, the font spacing\kerning becomes incorrect and some characters are noticeably out of position.

    I am using the Excel Chart.CopyPicture() and Word Range.Paste() methods from Interop versions 14.0 for both.

    I have tried all permutations of parameters and still cannot get this fixed.

    Many thanks


    Thursday, October 10, 2019 2:07 PM

All replies

  • I suspect that the problem here is to do with the fact that  the problem here is really to do with the fact that no matter what parameters you supply to the Excel CopyPicture method, what is being copied is a *picture* and not the Chart *object*

    When you do that, in theory what you end up with in Word will be either a windows metafile or enhanced metafile, and in theory you might hope that that would preserve the kerning characteristics that you set in the chart in Excel. But I don't think you can rely on that. 

    Instead, maybe it would be better to copy the *object*, e.g. using Chart.ChartArea.Copy, then paste that into Word using something like the following (this is VBA, you'd have to translate to C#and perhaps provide other parameter values):

    Range.PasteSpecial Link:=False, DataType:=wdPasteOLEObject

    Peter Jamieson

    Thursday, October 10, 2019 7:41 PM