I am trying to implement a error handling to my PowerPoint macro that restricts you to run the macro unless you are on slide 5. I am trying to utilize the command: "Application.ActiveWindow.View <> 5 Then" but it does not seem to recognize I am on slide 5, what is the correct comand for it ?
Private Sub CommandButton1_Click()
Dim Sld As Slide
Dim Shp As Shape
'ERROR HANDLING
If ActivePresentation.Slides.Count < 5 Then
MsgBox "You do not have any slides in your PowerPoint project."
Exit Sub
End If
Set Sld = Application.ActiveWindow.View.Slide
If activeSlide <> 5 Then
MsgBox "You are not on the correct slide."
Exit Sub
End If
Set Sld = Application.ActiveWindow.View.Slide
End Sub
Sld. Could you not say something likeIf Sld.Number <> 5 Then? Also, the secondSet Sldis not needed.