VBA removes other animation?!

G

Geoff Cox

Hello,

I have used the sub below to add a Sound Effect to an EndShow action
button (type 132).

This works fine - problem is that on the slide with the Action Button
all other animation is removed!

The animation is the type where words are moved across the slide when
the enter key is pressed.

Anyone see why this happens?

Thanks

Geoff

Sub add_sound (strMyFile As String)

Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)
With oPresentation
Dim oSl As Slide

For Each oSl In ActivePresentation.Slides
ActiveWindow.View.GotoSlide (oSl.SlideIndex)
Dim oSh As shape
Dim oHl As Hyperlink

For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then
If oSh.TextFrame.TextRange.Text <> "Classroom notes" Then
oSh.AnimationSettings.SoundEffect.Name = "Hammer"
End If
End If
End If

Next oSh
Next oSl

oPresentation.Save
oPresentation.Close

End With

Set oSh = Nothing
Set oPresentation = Nothing

End Sub
 
S

Shyam Pillai

This is a known bug. You should not use the older AnimationSettings when
coding in the newer versions (PPT2002 or later). Changing media animation
settings using the older object model in the new version will kill the
assigned animations. Use the new Timeline object instead.

Regards,
Shyam Pillai

Animation Carbon
http://animationcarbon.com
 
G

Geoff Cox

This is a known bug. You should not use the older AnimationSettings when
coding in the newer versions (PPT2002 or later). Changing media animation
settings using the older object model in the new version will kill the
assigned animations. Use the new Timeline object instead.

Shyam,

How do I use the Timeline object? It applies to a slide and not to a
shape? I'm confused!

oSh.AnimationSettings.SoundEffect.Name = "Hammer"

The above line is wrong - but how do I apply the Timeline object?

Geoff

For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then
If oSh.TextFrame.TextRange.Text <> "Classroom notes" Then

oSh.AnimationSettings.SoundEffect.Name = "Hammer"

End If
End If
End If
 
G

Geoff Cox

This is a known bug. You should not use the older AnimationSettings when
coding in the newer versions (PPT2002 or later). Changing media animation
settings using the older object model in the new version will kill the
assigned animations. Use the new Timeline object instead.

Shyam,

My aim is to add the Hammer sound effect to the already existing
EndShow button without deleting the other animation settings on that
slide, but cannot see how to do that using the Timeline object.

Fumbling my way forward the following code places an EndShow action
button on the slide which already has an EndShow action button on it
(with the idea of eventually deleting the current button and replacing
it with the new one which will have the sound effect) using the
Timeline object but I guess I need some parameters after Shape:=shpnew
on the line,

With sldNew.TimeLine.MainSequence.AddEffect(Shape:=shpnew)

I would like to add the Hammer sound effect and an EndShow hyperlink
to this new EndShow action Button but have no idea how to do it?!
Help!

Cheers

Geoff


For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then
Set shpnew =
oSl.Shapes.AddShape(Type:=msoShapeActionButtonEnd, Left:=25, Top:=25,
Width:=100, Height:=100)
With sldNew.TimeLine.MainSequence.AddEffect(Shape:=shpnew)

End With

End If
End If

Next oSh
Next oSl
 
S

Shyam Pillai

Geoff,
Based on your additional info. I think it would be simpler to just add sound
to the existing action setting instead of try to assign an animation to it.

With oSh.ActionSettings(ppMouseClick)
.Action = ppActionEndShow
.SoundEffect.ImportFromFile "C:\my sounds\hammer.wav"
End With


--
Regards,
Shyam Pillai

Toolbox
http://skp.mvps.org/toolbox
 
G

Geoff Cox

Geoff,
Based on your additional info. I think it would be simpler to just add sound
to the existing action setting instead of try to assign an animation to it.

With oSh.ActionSettings(ppMouseClick)
.Action = ppActionEndShow
.SoundEffect.ImportFromFile "C:\my sounds\hammer.wav"
End With

Thanks for the idea Shyam - will give it a go.

Cheers

Geoff
 
G

Geoff Cox

Geoff,
Based on your additional info. I think it would be simpler to just add sound
to the existing action setting instead of try to assign an animation to it.

With oSh.ActionSettings(ppMouseClick)
.Action = ppActionEndShow
.SoundEffect.ImportFromFile "C:\my sounds\hammer.wav"
End With


Shyam,

with the following code I am finding a type 132 (EndShow) button
and trying to add the sound to it - it's not working!?

Geoff

For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then
If oSh.TextFrame.TextRange.Text <> "Classroom notes" Then

With oSh.ActionSettings(ppMouseClick)
'.Hyperlink.Delete
'.Action = ppActionEndShow
.SoundEffect.ImportFromFile _
"C:\a-winfiles\hala\docs\power-point\sounds\online.wav"
End With

End If

End If

End If

Next oSh
Next oSl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top