Article ID: 172440
Article Last Modified on 10/11/2006
Sub StartShow()
' Change the path and file name to specify the presentation
' you want to open.
Const PRESENTATION_NAME As String = "c:\test.ppt"
' Used for error trapping.
On Error Resume Next
Err.Clear
' Declare the variables used in the message box.
Dim strPrompt As String
Dim strTitle As String
' Declare a variable to store an object reference to PowerPoint
' Viewer.
Dim oViewer As PowerPointViewer.Application
' Loop until GetObject fails. GetObject fails when no instances
' of PowerPoint Viewer are running.
Do
' Attempt to get a reference to the PowerPoint Viewer
' object model. If PowerPoint Viewer is running, GetObject
' returns a reference.
Set oViewer = GetObject(, "PowerPointViewer.Application.8")
' If GetObject succeeds, prompt to quit the PowerPoint Viewer.
If Err.Number = 0 Then
' Set up the strings used in the message box.
strPrompt = "Please quit all instances of Microsoft" _
& " PowerPoint Viewer 97 " & vbCrLf & "and click retry."
strTitle = "Quit Viewer 97"
' Display the message box.
Dim lResult As Long
lResult = MsgBox(strPrompt, vbRetryCancel + vbExclamation, _
strTitle)
' If user clicked Cancel, end the procedure.
If lResult = vbCancel Then
Exit Sub
End If
End If
Loop While Err.Number = 0
' Reset the Error object if needed.
If Err.Number <> 0 Then
Err.Clear
End If
' Launch and get reference to PowerPoint Viewer.
Set oViewer = CreateObject("PowerPointViewer.Application.8")
' Start a presentation in PowerPoint Viewer.
oViewer.NewShow PRESENTATION_NAME, ppViewerSlideShowManualAdvance, _
msoTrue
End Sub
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: vba pptview32 vbe object model 8.00
Keywords: kbbug kbcode kbdtacode kbmacro kbpending kbprogramming KB172440