Ad

Thursday, October 08, 2009

Embedding a SWF into PowerPoint

I was embedding multiple SWF files into PowerPoint, unfortunately when I set the ScaleMode to fit to area it would reset the next time I opened the PowerPoint file. A search of the internet did not come up with a solution to my problem. Since I couldn’t find out how to fix it I created a kludge to get the SWF videos to be sized correctly. To do this I created a button on the first slide.

image

I then created a macro to go along with the button.

Option Explicit

Private Sub CommandButton1_Click()

Dim oSlide As Slide

For Each oSlide In ActivePresentation.Slides
SlideShowWindows(1).View.Next
Dim oShape As Shape
For Each oShape In oSlide.Shapes
If oShape.Name = "ShockwaveFlash1" Then
Dim oShockwave As ShockwaveFlash
Set oShockwave = oShape.OLEFormat.Object
oShockwave.ScaleMode = 2
End If
Next
Next
SlideShowWindows(1).View.First
End Sub



The macro goes through each slide and sees if there is a SWF object named “ShockwaveFlash1”. If there is then the then the ScaleMode is set to 2, which is fit to the viewing area on the slide. If you renamed the SWF control name to something else, or have more than one SWF video on the page, then the code would need to be changed to reflect it. I noticed that the code didn’t work unless the slide was shown on the screen, which caused me to have to go through each slide. The code that moves through each slide is SlideShowWindows(1).View.Next line.



For some reason each Control on a slide is a Shape object. The SWF video is an OLE object. The last line of code before ending the Sub makes sure we go back to the first video.



This short screen cast goes over how to add a SWF to a PowerPoint slide: http://screencast.com/t/35dmmRfsdI

3 comments:

b.holliday said...

Hello Christopher,
I saw your article and wondered if you were able to tell me that it is possible to have a swf navigation movie on say slide 1 that can get you to other ppt slides. Do you know what the action script is for that Ive tried many variations of slide naming without success.

Kind regards,
Bruce

Christopher Fugitt said...

Here's how to go to a specific slide. The 3 would be the slide number. 1 is when the slideshow is showing.

Sub h()
SlideShowWindows(1).View.GotoSlide 3
End Sub

b.holliday said...

Hello Christopoher,
Thanks for the prompt response.
Within my xml file (the example code didnt get past your security)
there is a line of code to each url, url="acp.htm" target="_self", Im hoping that putting your code,
url="SlideShowWindows(1).View.GotoSlide 3
" target="_self", will achieve the result.
I'll let you know.

thanks,
Bruce

LinkWithin

Blog Widget by LinkWithin

Ad