Article ID: 170795
Article Last Modified on 11/9/2000
Microsoft PowerPointViewer 8.0 Object Library
Microsoft PowerPointViewer 8.0 Object Library
Sub ConnectToViewer()
' Used for error trapping.
On Error Resume Next
Err.Clear
' Declare a variable which is used to store an object
' reference to the 97 Viewer.
Dim oViewer As PowerPointViewer.Application
Dim bIsViewerRunning As Boolean: bIsViewerRunning = True
' Attempt to get a reference to the PowerPoint Viewer
' object model. If the Viewer is running GetObject will
' succeed.
Set oViewer = GetObject(, "PowerPointViewer.Application.8")
' Check if an error occurred when using GetObject
If Err.Number <> 0 Then
' Clear the error object.
Err.Clear
' GetObject failed, so lets try to create the object.
Set oViewer = CreateObject("PowerPointViewer.Application.8")
' Check if error occurred when using CreateObject.
If Err.Number <> 0 Then
' Enter code to handle the situation where GetObject and
' CreateObject fails.
MsgBox "Cannot find Microsoft PowerPoint Viewer 97.", _
vbCritical
' End the Macro.
End
End If
' The Viewer was started by the macro.
bIsViewerRunning = False
End If
' Display the name of the viewer in a message box.
MsgBox oViewer.Name
' Quit the viewer if started by the macro.
If bIsViewerRunning = False Then
oViewer.Quit
End If
End Sub
Keywords: kbmacro kbcode KB170795