none
Using the ChartUnitEffect Property RRS feed

  • Question

  • Hello,

    I have constructed a chart which looks exactly as i wish it to look using VSTO and C#.  It displays fine on the slide, and has an animation effect applied to it of ppEffectDissolve.  But when I try to use the statement:

         ppChart.AnimationSettings.ChartUnitEffect = PowerPoint.PpChartUnitEffect.ppAnimateByCategory;

    at runtime i get an error that says, "AnimationSettings (unknown member) : Invalid request.  Sorry, you can't set chart effects on objects that are not charts."

    I inserted the statement "Console.WriteLine(ppChart.HasChart.ToString());" just prior to the above statement, and it writes msoTrue, so I know that ppChart is a chart type of shape.  Of course, it displays on the slide as well.

    If i set a variable to the chart part (as in PowerPoint.Chart myChart = ppChart.Chart;) then I cannot use AnimationSettings on myChart.

    How do i make use of ChartUnitEffect?


    David

    Tuesday, November 13, 2012 7:24 PM

All replies

  • Hi David,

    Thanks for posting in the MSDN Forum.

    I can reproduce your issue in, and I can InvokeMember of "ChartUnitEffect" but I can't get the PropertyInfo of it.

    I will involve some experts into your thread to see whether they can help you. There might be some time delay, appreciate for you patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, November 14, 2012 6:37 AM
    Moderator
  • Hello David,

    Could you please share the sample code that you use to test this so that I can troubleshoot the issue further?

    Thanks,

    Sreerenj G Nair

    Wednesday, November 28, 2012 5:21 PM
  • Below is the method which creates the error.  All it requires is an valid powerpoint presentation.  The statement creating the error is about 4 lines from the bottom.

            private void BuildAChart2(PowerPoint.Presentation ppPresentation)
            {
                PowerPoint.Slide ppSlide = DpAddASlide(ppPresentation);
    
                // Create the basic chart
                PowerPoint.Shape ppChart = ppSlide.Shapes.AddChart(Office.XlChartType.xlColumnClustered);
    
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells.ClearContents();
    
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[2, 1] = "2/1/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[3, 1] = "2/2/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[4, 1] = "2/3/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[5, 1] = "2/4/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[6, 1] = "2/5/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[7, 1] = "2/6/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[8, 1] = "2/7/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[9, 1] = "2/8/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[10, 1] = "2/9/2012";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[11, 1] = "2/10/2012";
    
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[1, 2] = "Planned";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[2, 2] = 14;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[3, 2] = 20;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[4, 2] = 23;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[5, 2] = 17;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[6, 2] = 18;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[7, 2] = 16;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[8, 2] = 25;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[9, 2] = 13;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[10, 2] = 15;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[11, 2] = 12;
    
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[1, 3] = "Actual";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[2, 3] = 4;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[3, 3] = 10;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[4, 3] = 13;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[5, 3] = 7;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[6, 3] = 8;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[7, 3] = 6;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[8, 3] = 15;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[9, 3] = 3;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[10, 3] = 5;
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[11, 3] = 2;
    
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[1, 4] = "LTD Plan";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[2, 4] = "=B2";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[3, 4] = "=D2+B3";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[4, 4] = "=D3+B4";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[5, 4] = "=D4+B5";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[6, 4] = "=D5+B6";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[7, 4] = "=D6+B7";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[8, 4] = "=D7+B8";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[9, 4] = "=D8+B9";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[10, 4] = "=D9+B10";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[11, 4] = "=D10+B11";
    
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[1, 5] = "LTD Actual";
                ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[2, 5] = "=C2";
                for (int i = 3; i < 12; i++)
                    ppChart.Chart.ChartData.Workbook.ActiveSheet.Cells[i, 5] = "=E" + (i - 1).ToString() + "+C" + i.ToString();
    
                // Get a reference to the series collection
                PowerPoint.SeriesCollection mySeriesCollection = ppChart.Chart.SeriesCollection();
                // Remove all existing series in the collection
    
                while (mySeriesCollection.Count>0)
                    mySeriesCollection.Item(1).Delete();
    
                // Add Series number one
                mySeriesCollection.NewSeries();
                mySeriesCollection.Item(mySeriesCollection.Count).Values = "=Sheet1!B2:B11";
                mySeriesCollection.Item(mySeriesCollection.Count).Name = "=Sheet1!B1";
    
                // Add Series number two
                mySeriesCollection.NewSeries();
                mySeriesCollection.Item(mySeriesCollection.Count).Values = "=Sheet1!C2:C11";
                mySeriesCollection.Item(mySeriesCollection.Count).Name = "=Sheet1!C1";
    
                // Add Series number three
                mySeriesCollection.NewSeries();
                mySeriesCollection.Item(mySeriesCollection.Count).Values = "=Sheet1!D2:D11";
                mySeriesCollection.Item(mySeriesCollection.Count).Name = "=Sheet1!D1";
    
                // Add Series number four
                mySeriesCollection.NewSeries();
                mySeriesCollection.Item(mySeriesCollection.Count).Values = "=Sheet1!E2:E11";
                mySeriesCollection.Item(mySeriesCollection.Count).Name = "=Sheet1!E1";
    
                mySeriesCollection.Item(1).XValues = "=Sheet1!A2:A11";
                mySeriesCollection.Item(2).XValues = "=Sheet1!A2:A11";
                mySeriesCollection.Item(3).XValues = "=Sheet1!A2:A11";
                mySeriesCollection.Item(4).XValues = "=Sheet1!A2:A11";
    
    
                //Update the Title
                ppChart.Chart.HasTitle = true;
                ppChart.Chart.ChartTitle.Caption = "Sales Performance";
                ppChart.Chart.ChartTitle.Text = "Sales Performance";
                ppChart.Chart.ChartTitle.Format.TextFrame2.TextRange.Font.Name = "Tahoma";
    
    
                mySeriesCollection.Item(3).AxisGroup = PowerPoint.XlAxisGroup.xlSecondary;
                mySeriesCollection.Item(3).ChartType = Office.XlChartType.xlLineMarkers;
    
                mySeriesCollection.Item(4).AxisGroup = PowerPoint.XlAxisGroup.xlSecondary;
                mySeriesCollection.Item(4).ChartType = Office.XlChartType.xlLineMarkers;
    
    
                mySeriesCollection.Item(3).Format.Line.ForeColor.RGB = mySeriesCollection.Item(1).Format.Fill.ForeColor.RGB;
                mySeriesCollection.Item(3).MarkerForegroundColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White);
                mySeriesCollection.Item(3).MarkerBackgroundColor = mySeriesCollection.Item(1).Format.Fill.ForeColor.RGB;
                mySeriesCollection.Item(3).MarkerStyle = PowerPoint.XlMarkerStyle.xlMarkerStyleDiamond;
                mySeriesCollection.Item(3).MarkerSize = 8;
    
                mySeriesCollection.Item(4).Format.Line.ForeColor.RGB = mySeriesCollection.Item(2).Format.Fill.ForeColor.RGB;
                mySeriesCollection.Item(4).MarkerForegroundColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White);
                mySeriesCollection.Item(4).MarkerBackgroundColor = mySeriesCollection.Item(2).Format.Fill.ForeColor.RGB;
                mySeriesCollection.Item(4).MarkerStyle = PowerPoint.XlMarkerStyle.xlMarkerStyleTriangle;
                mySeriesCollection.Item(4).MarkerSize = 8;
    
    
                ppChart.Chart.Legend.IncludeInLayout = true;
                ppChart.Chart.Legend.Format.Fill.ForeColor.RGB = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.AliceBlue); // backColor does nothing
                ppChart.Chart.Legend.Format.Line.ForeColor.RGB = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.SeaGreen);
                
    
                // Label and format the Category (x) Axis
                PowerPoint.Axis myCategoryAxis = ppChart.Chart.Axes(PowerPoint.XlAxisType.xlCategory, PowerPoint.XlAxisGroup.xlPrimary);
                myCategoryAxis.HasTitle = true;
                myCategoryAxis.AxisTitle.Text = "Work Days";
                myCategoryAxis.AxisTitle.Format.TextFrame2.TextRange.Font.Bold = Office.MsoTriState.msoFalse;
    
                // Label and format the left (primary) y axis
                PowerPoint.Axis myPrimaryValueAxis = ppChart.Chart.Axes(PowerPoint.XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlPrimary);
                myPrimaryValueAxis.HasTitle = true;
                myPrimaryValueAxis.AxisTitle.Text = "Daily Count";
                myPrimaryValueAxis.AxisTitle.Format.TextFrame2.TextRange.Font.Bold = Office.MsoTriState.msoFalse;
                myPrimaryValueAxis.AxisTitle.Format.TextFrame2.TextRange.Font.Size = 12;
    
                // Label and format the right (secondary) y axis
                PowerPoint.Axis mySecondaryValueAxis = ppChart.Chart.Axes(PowerPoint.XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary);
                mySecondaryValueAxis.HasTitle = true;
                mySecondaryValueAxis.AxisTitle.Text = "LTD Count";
                mySecondaryValueAxis.AxisTitle.Format.TextFrame2.TextRange.Font.Bold = Office.MsoTriState.msoFalse;
                mySecondaryValueAxis.AxisTitle.Format.TextFrame2.TextRange.Font.Size = 12;
                mySecondaryValueAxis.AxisTitle.Orientation = -90;
    
                // Move the legend to the bottom of the chart
                ppChart.Chart.Legend.Position = PowerPoint.XlLegendPosition.xlLegendPositionBottom;
    
                ppChart.AnimationSettings.Animate = Office.MsoTriState.msoTrue;
                ppChart.AnimationSettings.AnimateBackground = Office.MsoTriState.msoTrue;
                ppChart.AnimationSettings.AdvanceMode = PowerPoint.PpAdvanceMode.ppAdvanceOnClick;
                ppChart.AnimationSettings.EntryEffect = PowerPoint.PpEntryEffect.ppEffectDissolve;
    
                Console.WriteLine(ppChart.HasChart.ToString());
    
                PowerPoint.Chart myChart = ppChart.Chart;
                Console.WriteLine(myChart.ToString());
    
                //////// This statement generates the error
                ppChart.AnimationSettings.ChartUnitEffect = PowerPoint.PpChartUnitEffect.ppAnimateByCategory;
    
                ppPresentation.Saved = Office.MsoTriState.msoTrue;
    
                ppChart.Chart.ChartData.Workbook.Close();
    
                return;
            }
    


    David

    Tuesday, December 4, 2012 12:39 AM
  • Hello David,

    I tested the code and I am able to reproduce the issue. I used the following code (from Office help) in VBA and the same error occurred.

    With ActivePresentation.Slides(1).Shapes(1)
      With .AnimationSettings
            .ChartUnitEffect = ppAnimateBySeries
            .EntryEffect = ppEffectFlyFromLeft
            .Animate = True
      End With
    End With

    This seems to be a bug with PowerPoint's chart object. I will go ahead and report this as bug.

    I tried to find a workaround for this but coulnd't find any.

    Thanks,

    Sreerenj G Nair

    Thursday, December 13, 2012 9:07 PM
  • Any updates on this?  A solution or work-around?

    David

    Thursday, January 3, 2013 3:56 PM
  • Hello David,

    I have already reported the bug and there is no further updates on it.

    As of now there is no workaround/solution available for this.

    Thanks,

    Sreerenj G Nair

    Friday, January 4, 2013 9:06 PM
  • Hello David,

    I have already reported the bug and there is no further updates on it.

    As of now there is no workaround/solution available for this.

    Thanks,

    Sreerenj G Nair


    After 6 years, the problem still exists. Weird.
    Friday, June 14, 2019 7:37 AM