Interop.PowerPoint: copy one chart data source to another RRS feed

  • Question

  • Sorry for my English


    Help me finish method which move source chart shape to destination chart shape according to the following logical:

    • assign source chart type to destination chart.
    • assing source chart data to destination chart.
    • everything else properties must be keep as destination chart


    using PP = Microsoft.Office.Interop.PowerPoint;
    using XL = Microsoft.Office.Interop.Excel;
    namespace SoInteropPp
        internal static class ChartSamples
            internal static void MoveChart(PP.Shape sourChart, PP.Shape destChart)
                // Validate
                if (sourChart.HasChart == MsoTriState.msoFalse || destChart.HasChart == MsoTriState.msoFalse)
                    throw new ArgumentException();
                // Process type.
                destChart.Chart.ChartType = sourChart.Chart.ChartType;
                // Move source chart data source to destination chart.
                var sourBook = sourChart.Chart.ChartData.Workbook as XL.Workbook;
                var destBook = destChart.Chart.ChartData.Workbook as XL.Workbook;

    My research

    If I have understood correctly, need

    1. Define which worksheet in sourBook contains source chart data.
    2. Define which range of worksheet contains data source.
    3. Copy got range (step 2) to destination worksheet
    4. Assign copied range to destChart via destChart.SetSourceData().


    I cannot (do not know) implement steps described above via Interop.PowerPoint APIs. How archive these steps or there is may be another some way?

    Thursday, August 9, 2018 8:47 PM