Question Powerpoint Run Show and select a Specific Slide

dHeather

Active member
Joined
Jun 18, 2012
Messages
27
Programming Experience
Beginner
Hello,

I am writing a program that detects a signal (1 to 8) from a serial port and then displays the corrosponding slide number in a powerpoint presentaion.

I am struggling with two items though and would greatly appreciate any help:

How do you run a slide show from VB.Net?

Also how do you select a particular slide once the show is running?

This is my code so far (currently working on a button press). Thanks
Private Sub All_Buttons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click
Dim CurrentButton As Button = sender
CurrentPort = CurrentButton.Name.Chars(6)
Dim SlideToShow As Integer = CurrentPort + 0

Try
oPP = GetObject(, "PowerPoint.Application")
Catch ex As Exception
Try
oPP = CreateObject("PowerPoint.Application")
Catch ex1 As Exception
MessageBox.Show("Can not find working version of PowerPoint", "Program Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Exit Sub
End Try
End Try

Try
oPPPres = oPP.Presentations("Switch.pptx")
Catch ex As Exception
Try
oPPPres = oPP.Presentations.Open("C:\Switch.pptx")
Catch ex1 As Exception
MessageBox.Show("Can not find the Switch.ppt." & Chr(13), "Disk Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
oPP.Visible = True
Exit Sub
End Try
End Try

oPP.Visible = True

oPPSlide = oPPPres.Slides(SlideToShow).Select

Try
oPP.Application.WindowState.Maximized()
Catch ex As Exception
End Try

oPPPres = Nothing
oPPSlide = Nothing
oPP = Nothing
End Sub
 
Just worked out how to run the slide show:

I have replaced oPPSlide = oPPPres.Slides(SlideToShow).Select with oPPPres.SlideShowSettings.Run()

Just need to detect if it is already running and select a slide now.
 
Turns out it was very simple in the end. I replaced the above with:
With
oPPPres.SlideShowSettings.Run.View
.GoToSlide(SlideToShow)
End With

Working fine now

Thanks

 
Back
Top