PPT97: NewShow Method Doesn't Start Slide Show If Viewer Running

ID: Q172440

The information in this article applies to:

SYMPTOMS

When you use the NewShow method (which is part of the Microsoft PowerPoint Viewer 97 object model) to start a slide show, the computer screen becomes black, and the show does not start. Pressing the ESC key does not close the show, so you must press ALT+TAB to switch to PowerPoint Viewer 97, and then click Exit. The first slide of the show appears, and then the show ends.

CAUSE

This problem occurs if PowerPoint Viewer is running when you obtain an object reference to it.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

To work around this problem, use GetObject. If GetObject succeeds (obtains an object reference to PowerPoint Viewer), prompt the user to quit any instances of PowerPoint Viewer. When all instances of PowerPoint Viewer are terminated, use CreateObject to obtain an object reference. The following sample Visual Basic for Applications procedure demonstrates this technique.

   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

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

REFERENCES

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications

Additional query words: vba pptview32 vbe object model 8.00
Keywords          : kbcode kbmacro kbprg kbdta kbdtacode 
Version           : WINDOWS:97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: May 17, 1999