Microsoft KB Archive/276353

From BetaArchive Wiki
Knowledge Base


Article ID: 276353

Article Last Modified on 10/11/2006



APPLIES TO

  • Microsoft PowerPoint 2000 Standard Edition



This article was previously published under Q276353

SUMMARY

The sample code in this article creates an event handler for your presentation that allows you to go backward and restart the animations on previously viewed slides.

MORE INFORMATION

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, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

Code Sample

  1. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  2. On the Insert menu, click Class Module.

    PowerPoint inserts a module called Class1 into your project.
  3. In the Class1 module window, type the following code:

    Public WithEvents appevent As Application
    '
    ' Declare lCurrSlidePos to keep track of the current slide
    ' during the slide show. This is used to prevent this code
    ' from endlessly looping.
    '
    Dim lCurrSlidePos As Long
    
    Private Sub appevent_SlideShowBegin(ByVal Wn As SlideShowWindow)
    '
    ' Initialize lCurrSlidePos to 0.
    '
       lCurrSlidePos = 0
    End Sub
    
    Private Sub appevent_SlideShowEnd(ByVal Pres As Presentation)
    '
    ' Stop the event handler from running when the slide show ends.
    '
       Set Module1.myobject.appevent = Nothing
    End Sub
    
    Private Sub appevent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    '
    ' If the current slide position is different from the saved
    ' position, set lCurrSlidePos to the current position
    ' and then refresh the current slide, restarting the animations.
    ' All of the previously built objects on the slide are 
    ' briefly visible as the slide refreshes.
    '
       If lCurrSlidePos <> Wn.View.CurrentShowPosition Then
          lCurrSlidePos = Wn.View.CurrentShowPosition
          Wn.View.GotoSlide lCurrSlidePos, msoTrue
       End If
    End Sub
                        
  4. On the Insert menu, click Module.
  5. Type the following Visual Basic for Applications code in the module:

    '
    ' Declare myobject as an instance of Class1 and make
    ' it public, so that the Class1 module can access it,
    ' and use it to stop the event handler.
    '
    Public myobject As New Class1
    
    Sub StartEvents()
    '
    ' Start the event handling.
    '
       Set myobject.appevent = Application
    '
    ' Start the slide show and use the default Slide Show settings.
    '
       ActivePresentation.SlideShowSettings.Run
    End Sub
                        

To run the slide show automatically, simply run the StartEvents macro.

REFERENCES

For additional information about how to create event handlers, click the article number below to view the article in the Microsoft Knowledge Base:

234184 PPT2000: How to Create Application Level Event Handlers



Additional query words: vba rebuild builds button action settings

Keywords: kbdtacode kbhowto KB276353