Rewind Flash Movies Using VBA

Created: Saturday, August 11, 2007, posted by Geetesh Bajaj at 9:30 am



I already discussed why you would want to rewind your Flash movies, the ones you insert into PowerPoint slides.

Now let me show you how you can do that with a little VBA code. Remember though that this code is dependent on ActiveX controls that are not supported by both the free PowerPoint Viewer on Windows, and PowerPoint on the Mac. So this will only work on PowerPoint 97 or higher for Windows.

  1. First, create a backup copy of your presentation, just in case.
  2. Open the presentation in PowerPoint — this presentation must have a Flash movie inserted as per the instructions provided here…

  3. Make sure that the Loop option in the Property Pages dialog is left unchecked.
  4. Save the presentation.
  5. Press Alt F11 to bring up the Microsoft Visual Basic window (see Figure 1).


    Figure 1: The Visual Basic window is where you add code in PowerPoint.

  6. Choose Insert | Module. This adds a new module in the left pane, as you can see in Figure 2.


    Figure 2: A new module has been added.

  7. In the main window, add the following code, while making sure that the number in the 3rd line after the word “Slides” is the number of the slide in your presentation that contains the Flash movie.

    Sub OnSlideShowPageChange()
    Dim obj As ShockwaveFlash
    Set obj = ActivePresentation.Slides(2).Shapes(“ShockwaveFlash1”).OLEFormat.Object
    obj.Playing = True
    obj.Rewind
    obj.Play
    End Sub

    Figure 3 shows you the main window after the code was added:


    Figure 3: Code has been added.

    As you can see, the code simply sets the Playing property to true, rewinds the movie, and plays it.

    Also, if your presentation contains more than one Flash movie, you’ll need to repeat this process for each movie. However, change the numbering in the 3rd line again after the word ShockwaveFlash, so that you name them ShockwaveFlash1, ShockwaveFlash2, and so on. Then, in the Properties window, give the object the same name in the Name row, which is just under the Custom row (see Figure 4).


    Figure 4: Match the object names in the Visual Basic window, and the Property window.

  8. That’s all you need to do — return to your presentation, save it, and play it to test.

Remember, your macro security settings may stop the VBA code from executing. In PowerPoint, choose Tools | Options | Security | Macro Security, and make sure it isn’t set to High. In addition, coding in the Flash file itself may stop the movie from playing.

I wish to thank Ellen Finkelstein, author of How To Do Everything with PowerPoint 2007 for providing the VBA code used in this tutorial. You can visit Ellen’s site here…


Related Posts

  • What is FlashBack?
    FlashBack is a free PowerPoint add-in from Shyam Pillai, a Microsoft PowerPoint MVP that rewinds a Flash movie so that it plays from the starting fram...
  • Rewind a Flash Movie?
    Why would you want to rewind a Flash movie placed in a PowerPoint slide? That's because in certain scenarios, the Flash movie you insert might not pla...
  • Insert the Control (PowerPoint 2007)
    I'm assuming you have the Developer tab of the ribbon enabled, have all the prerequisites installed, and have assembled everything in one folder.Now y...
  • Enable the Developer tab in the Ribbon
    The options that allow you to insert Flash movies in PowerPoint 2007 (and maybe later versions) are found in the Developer tab of the Ribbon.By defaul...

Filed Under: Insert, Rewind

8 Comments

8 responses to “Rewind Flash Movies Using VBA”

  1. Anonymous says:

    i try to get it with ppt 2003 and it doesn’t work:( why???

  2. Geetesh says:

    Can you explain in more detail where you get stuck?

  3. Anonymous says:

    i copy this code (or the code from here http://support.microsoft.com/kb/291876/en-us) and do all, what here is described, all points, but it does not work anyway. my flash does not react to any functions, any events… it plays always forward.

    p.s. sorry for my english:)

  4. Anonymous says:

    Thank you very much, this works like a charm (using ppt 2007). I am not much of a programmer, I should know more, but I knew that previous code I found on the net didn’t work.

    Something about my embedded movies not loading in VBA as flash objects.

    Anyways, Thank You

  5. Anonymous says:

    Big thanks form me! Before your tutorial (with 0,001% VBA knowledge) I couldn't find out how to script the object. So thanks for providing the missing piece! 🙂

  6. phil says:

    Hi there, did u know that if u have a swf on slide 2 (with music), it'll start playing the music when u open the presentation?

    I got a swf (with music) on slide 2 and 4 and im trying to find a way to do the following:

    Enter Slide 2+4:
    Rewind and play

    Leaving Slide 2+4:
    Stop and Rewind

  7. Ryan Dumas says:

    Thias you a million times. Good stuff.

  8. Mario Fonseca says:

    Thank you! It help a lot also. I am inserting several swf with the same name in different slides and I am using the number of the current slide dynamically so I do not need to modify slide numbers…:

    Sub OnSlideShowPageChange()
    Dim obj As ShockwaveFlash
    i = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
    Set obj = ActivePresentation.Slides(i).Shapes("ShockwaveFlash1").OLEFormat.Object
    obj.Playing = True
    obj.Rewind
    obj.Play
    End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.

Plagiarism will be detected by Copyscape

© 2007-2024, Geetesh Bajaj - All rights reserved.

blog stats
since September 16, 2009