Search code examples
c#vstopowerpointoffice-interopcom-interop

how to multiple select programmatically in PowerPoint


I want to programmatically select 2 shapes A and B from a set of shapes in a specific slide in PowerPoint, and then perform the "Cut" action. How can I do that?

Note: I am using C#, Visual Studio 2013, PowerPoint 2013


Solution

  • Since you also tagged with PowerPoint-VBA, that's the example I'll provide here. This will select shapes 1 and 3 on the first slide of the active presentation then cut them:

    Sub SelectShapes()
    
        With ActivePresentation.Slides(1)
            .Shapes(1).Select msoTrue  ' Start a new selection
            .Shapes(3).Select msoFalse ' Add to current selection
        End With
    
        ' and cut
        ActiveWindow.Selection.Cut
    
    End Sub