Pause/Restart a Power Point show with VB.Net
-
Thursday, October 14, 2010 6:32 AM
Hi
I need a way for my console application to pause a running PPS power point show so that it can update files then when this is done restart the slide show.
I have created a macro in the presentation that will pause for n' seconds then continue on but it's the actual accessing the running show to run that macro that I'm having trouble with.
My code appears to work but the slide show does not restart and it leaves an instance of the power point object as the front most window which needs to disappear
Code:
Imports Office = Microsoft.Office.Core
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint
Imports System.Threading
Module Module1
Dim oPP As PowerPoint.ApplicationClass
Dim oPresSet As PowerPoint.Presentations
Dim oPres As PowerPoint.PresentationClass
Dim MySlide As PowerPoint.Slide
Dim myThread As Thread
Sub Main()
Dim DelaySecs As Integer = 10
Console.SetWindowSize(1, 1)
myThread = New thread(AddressOf TestThread) 'Creates a new thread
myThread.Start()
'myThread.IsBackground = True ' Didn't seem to do much
'MsgBox("Thread started")
End Sub
Sub TestThread()
Dim oPP As Object
Dim i As Integer
'Dim OpenPres As String = "C:\PowerpointTest.pps"
'oPP = CreateObject("PowerPoint.Application") 'no need to create if PP is running
oPP = GetObject(, "PowerPoint.Application")' Seem to communicate with the running PPS show
oPresSet = oPP.Presentations
i = oPP.SlideShowWindows.Count
If i > 0 Then
oPP.Run("'PowerpointTest.pps'!CallWait") 'Run the macro to Pause the pps Show - this actually appear to work
oPresSet.Application.Activate()
oPresSet = Nothing
'oPP.Quit() 'This quit all Power point processes running
oPP = Nothing
End If
myThread.Abort()
end sub
Can anyone point me in the direction as to how I can get rid of the active power point window and have the presentation start running again. It is causing me no end of trouble as the presentation updates links every time through and if I am saving a file that it links to the VB app fails!
Many thanks

