none
Selection.Type == ppSelectionShapes, but Selection.ShapeRange is empty. RRS feed

  • Question

  • Hi,

    I found a possible bug in PowerPoint 2013 (with all Updates).

    To reproduce this do following.

    1. Open a new blank presentation.
    2. Add any chart on the first slide
    3. Now add any shape (e. g. Oval) inside the chart of 2). If you are moving the chart, the shape must be moved too.
    4. Select the inserted shape

    Now if you run following code, you get an error ("Integer out of range. 1 is not in the valid range of 1 to 0.")
    In debugger I can see that Selection.ShapeRange is empty, even though Selection.Type == ppSelectionShapes.

    if (PowerPointApp.ActiveWindow.Selection.Type == MSPowerPoint.PpSelectionType.ppSelectionShapes) { MSPowerPoint.Shape shape = PowerPointApp.ActiveWindow.Selection.ShapeRange[1]; if (PowerPointApp.ActiveWindow.Selection.HasChildShapeRange) { shape = PowerPointApp.ActiveWindow.Selection.ChildShapeRange[1]; }

    // Do something with shape

    }

    How can I get a reference to selected shape? I believe this is a Bug in PowerPoint.

    Regards,
    Daniel

    Thursday, January 28, 2016 10:55 AM

Answers

  • Hi Daniel,

    Thanks for reporting this issue.

    After the further investigation, this behavior is relative how you draw the shape. If you select the chart and then draw the shape over a char then the PowerPoint application believe that the shape is part of the chart and there is no shapes on the slide. To confirm this issue, we can show the "Selection Pane".

    As a workaround, we can unselect the chart before we draw a new shape or draw the shape outside of the chart then move it the position we want.

    And if you have any feedback about this feature, you can try to submit the feedback from link below:
    Welcome to PowerPoint's Suggestion Box! - UserVoice

    Regards & Fei


    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.

    Monday, February 1, 2016 3:32 AM
    Moderator

All replies

  • Hi Daniel,

    I noticed that your issue is code related. It is better to ask a question in Office for Developers forum for more help. We have moved this thread to general Office Development forum. And hope you can find the solution here.

    Regards,


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Winnie Liang
    TechNet Community Support

    Friday, January 29, 2016 7:29 AM
  • Hi Liang, #

    thank you for moving this to the correct forum.

    Above my code is written in C#. I tested my scenario with classic VBA too and can confirm the same failing behavior.

    Sub test()
    
        If Application.ActiveWindow.Selection.Type = ppSelectionShapes Then
        
            Dim myShape As shape
            
            ' Following line throws an exception, if you select the shape inside the chart
            Set myShape = Application.ActiveWindow.Selection.ShapeRange(1)
            If Application.ActiveWindow.Selection.HasChildShapeRange Then
                Set myShape = Application.ActiveWindow.Selection.ChildShapeRange(1)
            End If
           
        End If
    
    End Sub
    

    Regards,
    Daniel

    Friday, January 29, 2016 8:59 AM
  • >>>Above my code is written in C#. I tested my scenario with classic VBA too and can confirm the same failing behavior.

    According to your description and sample codes, I have reproduced this issue, if you want to manipulate shapes embedded within charts, I suggest that you could refer to below code:

    If ActiveWindow.Selection.Type = ppSelectionShapes And _
    ActiveWindow.Selection.ShapeRange.Count = 0 Then
    
        For Each shp In ActiveWindow.View.Slide.Shapes
               If shp.HasChart Then
                   Debug.Print shp.Chart.ChartType
                   Debug.Print shp.Chart.Shapes.Count
                    For Each sp In shp.Chart.Shapes
                        sp.TextFrame.TextRange.Text = "Test"
                        sp.Delete
                    Next sp
               End If
        Next shp
        
    End If
    

    In addition if you have any feedbacks for Access, please feel free to submit them to User Voice:

    https://powerpoint.uservoice.com/

    Thanks for your understanding.

    Monday, February 1, 2016 3:06 AM
  • Hi Daniel,

    Thanks for reporting this issue.

    After the further investigation, this behavior is relative how you draw the shape. If you select the chart and then draw the shape over a char then the PowerPoint application believe that the shape is part of the chart and there is no shapes on the slide. To confirm this issue, we can show the "Selection Pane".

    As a workaround, we can unselect the chart before we draw a new shape or draw the shape outside of the chart then move it the position we want.

    And if you have any feedback about this feature, you can try to submit the feedback from link below:
    Welcome to PowerPoint's Suggestion Box! - UserVoice

    Regards & Fei


    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.

    Monday, February 1, 2016 3:32 AM
    Moderator
  • Hi Fei,

    many thanks for your Response.

    Unfortunately your answer is not a possible workaround/solution for me/users.
    For me this is a bug in PowerPoint. Should I have to report this to Microsoft, or is MS following this forum.

    Regards,
    Daniel

    Friday, February 5, 2016 1:08 PM
  • Hi Daniel,

    This forum is for developers discussing developing issues involve Microsoft Office. There is no guarantee the MS will follow this forum.

    You can try contacting Microsoft support to raise an incident so that our engineer could work closely with him to identify the root cause and resolve this issue as soon as possible.

    If the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged.

    Please visit the below link to see the various paid support options that are available to better meet your needs.
    https://msdn.microsoft.com/subscriptions/bb266240.aspx

    Regards & Fei


    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.

    Tuesday, February 23, 2016 2:13 AM
    Moderator