none
Excel Window Popping Up while Adding Chart in PowerPoint

    Question

  • Hi, 

    Can someone please help me into this? 

    I'm executing below code from my application,

    chart = slide.Shapes.AddChart(XlChartType.xlLineMarkers, shapeLeft, shapeTop, shapeWidth, shapeHeight).Chart


    Once this line gets execute, it's poping-up Excel window....I don't want to let the excel window pop-up. 

    Any idea please?? 

    The complete code is as below :

     

     

    Private Function SetSlideCharts(ByVal slide As PowerPoint.Slide, ByVal graphID As String, ByVal setData As Action(Of PowerPoint.Chart)) As PowerPoint.Chart
    

    Dim chart As PowerPoint.Chart = Nothing
    Dim dataLables As PowerPoint.DataLabels
    Dim objAxes As PowerPoint.Axes
    Dim objSeriesCollection As PowerPoint.SeriesCollection
    Dim objSeries As PowerPoint.Series = Nothing
    Dim objapp As Excel.Workbook = Nothing

    Dim shapeHeight, shapeWidth, shapeTop, shapeLeft As Single
    'get the shape object that need to be substituted with graph
    Dim shape = slide.Shapes.FindShape(graphID)
    If shape Is Nothing Then Return Nothing

    shapeHeight = shape.Height
    shapeWidth = shape.Width
    shapeTop = shape.Top
    shapeLeft = shape.Left

    shape.Delete()

    chart = slide.Shapes.AddChart(XlChartType.xlLineMarkers, shapeLeft, shapeTop, shapeWidth, shapeHeight).Chart

    With (chart)
    .Legend.Position = PowerPoint.XlLegendPosition.xlLegendPositionBottom
    .Legend.Format.TextFrame2.TextRange.Font.Size = 8

    'cast and get the Axes of the chart
    objAxes = DirectCast(.Axes, PowerPoint.Axes)
    objAxes.Item(PowerPoint.XlAxisType.xlValue).HasMajorGridlines = False
    objAxes.Item(PowerPoint.XlAxisType.xlCategory).TickLabels.Font.Size = 8
    objAxes.Item(PowerPoint.XlAxisType.xlValue).TickLabels.Font.Size = 8
    objAxes.Item(PowerPoint.XlAxisType.xlCategory).TickLabels.Orientation = PowerPoint.XlTickLabelOrientation.xlTickLabelOrientationUpward
    End With

    End Sub

     


    Thanks

    Thursday, February 10, 2011 6:50 AM

Answers

  • Hi naimish

    I bugged this during Office 2010 beta and was told the behavior is "by design" and won't be changed. This is the way the UI functions.

    What you could do would be to create the chart in Excel (using either the interop or OpenXML), then import (insert) that file into PowerPoint.


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bessie Zhao Monday, February 14, 2011 8:00 AM
    • Marked as answer by Bessie Zhao Wednesday, February 16, 2011 6:57 AM
    Thursday, February 10, 2011 6:25 PM

All replies

  • Hi naimish

    I bugged this during Office 2010 beta and was told the behavior is "by design" and won't be changed. This is the way the UI functions.

    What you could do would be to create the chart in Excel (using either the interop or OpenXML), then import (insert) that file into PowerPoint.


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bessie Zhao Monday, February 14, 2011 8:00 AM
    • Marked as answer by Bessie Zhao Wednesday, February 16, 2011 6:57 AM
    Thursday, February 10, 2011 6:25 PM
  • Hi Cindy,

     

    Thank you very much for your help.

     

    So that means I am helpless :(

     

    Your suggestion is nice, I would try to implement the same.

     

    Thanks

    Naimish

    Friday, February 11, 2011 8:54 AM