1

I am trying to create a macro that opens a pp, and then move forward one slide and make it my active slide. I feel like there is a simple solution to this but i cant seem to find a code to move me forward one slide. so far i have

Private Sub OpenPowerpoint()
' Opens Presentation.pptx

Dim PPT As PowerPoint.Application
Set PPT = New PowerPoint.Application
PPT.Visible = True
PPT.Presentations.Open Filename:="C:\Users\Person\Desktop\Test\Template.pptx"

End Sub

which open my pp on the first slide.

2 Answers 2

1

Window.View.GoToSlide will let you go to a specific Slide number.
 
Window.View.Slide.SlideIndex will tell you which Slide number you are currently on.
 
Presentation.Slides.Count will tell you how many slides there are in a Presentation, so that you don't try to move past the end.
 
Put it together:

Private Sub OpenPowerpoint()
    ' Opens Presentation.pptx

    Dim PPT As PowerPoint.Application, PPP As PowerPoint.Presentation, PPW As Object
    Set PPT = New PowerPoint.Application
    PPT.Visible = True
    Set PPP = PPT.Presentations.Open(FileName:="C:\Users\Person\Desktop\Test\Template.pptx")
    Set PPW = PPP.Windows(PPP.Windows.Count)
    'If there are more slides, go to the next one
    If PPW.View.Slide.SlideIndex < PPP.Slides.Count Then PPW.View.GotoSlide PPW.View.SlideIndex + 1
End Sub
Sign up to request clarification or add additional context in comments.

Comments

0

You are almost there - with your code, just add PPT.ActivePresentation.Slides(2).Select:

Private Sub OpenPowerpoint()

    Dim PPT As PowerPoint.Application
    Set PPT = New PowerPoint.Application

    PPT.Visible = True
    PPT.Presentations.Open Filename:="C:\Users\Person\Desktop\Test\Template.pptx"        
    PPT.ActivePresentation.Slides(2).Select

End Sub

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.