Error - Invalid request. To select a shape its view must be active
excel, powerpoint, vba
Solution
Use
ActiveWindow.View.GotoSlide oSlide.SlideIndex
to activate the view before you select the shape on the slide:
More information can be found here
Problem
I am new to VBA. I am writing code to copy paste charts from excel to different slides of a powerpoint presentation. I am able to paste chart on slide 1 of a ppt in perfect alignment; but for the 2nd chart I am getting an error saying: "Invalid request. To select a shape its view must be active.". Would request all to support me on correcting this code below: ``` Sub ExcelAuto() Dim PPT As PowerPoint.Application Dim PPTFile As PowerPoint.Presentation Dim ActiveSlide As PowerPoint.Slide Set PPT = CreateObject("PowerPoint.Application") PPT.Visible = True PPT.Presentations.Open fileName:="Path" Set PPTFile = PPT.ActivePresentation PPT.ActiveWindow.ViewType = ppViewSlide ActiveWorkbook.Sheets("Charts").ChartObjects("Chart 6").CopyPicture With PPTFile.Slides(1) .Shapes.Paste.Select PPT.ActiveWindow.Selection.ShapeRange.Left = 37 PPT.ActiveWindow.Selection.ShapeRange.Top = 127 End With ActiveWorkbook.Sheets("Charts").ChartObjects("Chart 8").CopyPicture With PPTFile.Slides(2) .Shapes.Paste.Select PPT.ActiveWindow.Selection.ShapeRange.Left = 37 PPT.ActiveWindow.Selection.ShapeRange.Top = 354 End With Set PPT = Nothing Set PPTFile = Nothing Set ActiveSlide = Nothing End Sub ```