none
Creating a new chart in PowerPoint 2013 with Chart Styles applied RRS feed

  • Question

  • In PowerPoint 2013 when I manually insert a new chart into a slide, the chart automatically has the Chart Style "Style 1" applied. This has the effect of setting the font sizes of chart labels to 12.

    However, no Chart Styles are applied if I try to add a new chart to PowerPoint 2013 using the following C# code:

    var ppt = new Microsoft.Office.Interop.PowerPoint.Application();
    var presentation = ppt.Presentations.Add();
    var layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutChart;
    var slide = presentation.Slides.Add(1, layout);
    var shapes = slide.Shapes;
    shapes.AddChart();

    Font sizes seem to default to 18. Is there any way to create a chart or to set Chart Styles using Interop so that it matches a chart produced manually (i.e. has Chart Styles applied)?

    I am aware of the Chart.ChartStyle property but it only seems to change chart colors and legend placement, not font size. There is no Macro recorder in PowerPoint, so I can't generate VBA code to replicate the action of creating a new chart.

    Monday, March 16, 2015 2:44 AM

Answers

  • Hi

    >> there any way to create a chart or to set Chart Styles using Interop so that it matches a chart produced manually (i.e. has Chart Styles applied)?

    You can add using shapes.AddChart2() instead of the last sentence shapes.AddChart(), I have tested in my projects, if I using AddChart(), the label size and the space will be different from manually insert a chart into a slide, but AddChart2() is the same with manually operating.

    And This object, member, or enumeration is deprecated and is not intended to be used in your code. More details you cab refer to the following link

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.shapes.addchart.aspx

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by L.HlModerator Friday, March 27, 2015 7:49 AM
    • Marked as answer by L.HlModerator Sunday, March 29, 2015 3:24 PM
    Tuesday, March 17, 2015 8:37 AM
    Moderator