Try this line:
VB:Activewindow.View.GotoSlide ActiveWindow.View.Slide.slideindex + 1
I have an Excel spreadsheet with one chart per sheet and an open Powerpoint presentation with one slide created for each of these charts. What I am trying to do is create a macro to copy the first chart in to the first slide of Powerpoint and then go to the next sheet in Excel and the next slide in Powerpoint (note: I do not want to add a new slide, only to go to the next one) so I can repeat the macro again.
Everything in my code is working perfectly except for the part where I need to switch to the next slide. I've tried various things and I've searched the internet but can't find a solution, can anyone help?
I am a beginner to this and I realize this is probably a simple solution but I can't figure it out for the life of me.
Thanks in advance!
VB:Sub PasteChartintoPP2() ' ' PasteChartintoPP Macro ' Keyboard Shortcut: Ctrl+Shift+A Dim PPApp As PowerPoint.Application Dim PPPres As PowerPoint.Presentation Dim PPSlide As PowerPoint.Slide Dim PresentationFileName As Variant ' Reference existing instance of PowerPoint Set PPApp = GetObject(, "Powerpoint.Application") ' Reference active presentation Set PPPres = PPApp.ActivePresentation ' Reference active slide Set PPSlide = PPPres.Slides _ (PPApp.ActiveWindow.Selection.SlideRange.SlideIndex) ' Copy chart in sheet and go to next sheet ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.ChartArea.Copy ActiveSheet.Next.Select ' Paste chart PPSlide.Shapes.Paste.Select ' Align pasted chart PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True PPApp.ActiveWindow.Selection.ShapeRange.ScaleWidth 1.39, msoFalse, msoScaleFromTopLeft PPApp.ActiveWindow.Selection.ShapeRange.ScaleWidth 1.35, msoFalse, msoScaleFromBottomRight PPApp.ActiveWindow.Selection.ShapeRange.ScaleHeight 1.6, msoFalse, msoScaleFromTopLeft ' Go to next slide in presentation PPApp.ActiveWindow.View.Next ' Clean up Set PPSlide = Nothing Set PPPres = Nothing Set PPApp = Nothing End Sub
Aha! Got it figured out (thanks to your help).
I altered the text a little bit and wrote out:
And it works like a charm now, thanks for the help!VB:PPApp.ActiveWindow.View.GotoSlide (PPApp.ActiveWindow.View.Slide.SlideIndex + 1)
There are currently 1 users browsing this thread. (0 members and 1 guests)