Microsoft KB Archive/285467

= PowerPoint and the Visual Basic Editor do not quit as expected on the Application.Quit event =

Article ID: 285467

Article Last Modified on 6/4/2007

-

APPLIES TO


 * Microsoft Office PowerPoint 2007
 * Microsoft PowerPoint 2002 Standard Edition

-



This article was previously published under Q285467





SYMPTOMS
You run a Microsoft Visual Basic for Applications (VBA) macro from within the Visual Basic Editor that includes an Application.Quit event. When you do this, Microsoft Office PowerPoint 2007, Microsoft PowerPoint 2002, and the Visual Basic Editor may not close as expected. The same macro does cause Microsoft PowerPoint 2000 and the Visual Basic Editor to close.



CAUSE
This behavior occurs when all of the following conditions are true:
 * The macro closes the active presentation.
 * The Application.Quit event occurs after the active presentation is closed.
 * The presentation that the macro belongs to is not the last presentation that is open.

For example, if you run the following macro in a presentation from the Visual Basic Editor and not from PowerPoint, you experience the problem that is mentioned in the &quot;Symptoms&quot; section. Sub A For Each oPres In Application.Presentations If Not oPres.Saved And oPres.Path <> &quot;&quot; Then oPres.Save Else oPres.Saved = True End If   oPres.Close Next Application.Quit End Sub If there are four presentations open when this code is run, and the presentation that the macro is associated with is the third one in the Window menu's list of open presentations, the fourth presentation remains open.

PowerPoint 2000 retains the macro in memory until it is finished running. However, PowerPoint 2002 unloads the macro from memory the instant that the presentation that holds it is closed when the macro is run from the Visual Basic Editor.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this problem, remove the command that closes the active presentation. The earlier sample macro can be changed to the following sample, in which case, PowerPoint and the Visual Basic Editor quit as expected. Sub A For Each oPres In Application.Presentations If Not oPres.Saved And oPres.Path <> &quot;&quot; Then oPres.Save Else oPres.Saved = True End If  Next Application.Quit End Sub



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Additional query words: PPT2002 PPT2007

Keywords: kbbug kbpending KB285467

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.