VBA question

G

Geoff Cox

Hello,

code below work and adds Entrance/dissolve animation to all the type
129 action buttons.

Just wondered what happens if the button already has that animation?
Apparently nothing?

Would it be better to check first and only if not present then add it?
Not sure how to do that?

Thanks

Geoff

Dim oSl As Slide

For Each oSl In ActivePresentation.Slides

Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 129 Then
With oSh.AnimationSettings
.Animate = msoTrue
.EntryEffect = ppEffectDissolve
.TextLevelEffect = ppAnimateByAllLevels
.AnimateBackground = msoTrue
End With
End If
End If
Next oSh
Next oSl
 
G

Geoff Cox

Would it be better to check first and only if not present then add it?
Not sure how to do that?

I may have answered my own question! But would appreciate any
comments.

Cheers

Geoff

For Each oSl In ActivePresentation.Slides

ActiveWindow.View.GotoSlide (oSl.SlideIndex)

Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 129 Then
If oSh.TextFrame.TextRange.Text <> "When finished"
Then
If oSh.AnimationSettings.Animate <> _
ppEffectDissolve Then
With oSh.AnimationSettings
.Animate = msoTrue
.EntryEffect = ppEffectDissolve
.TextLevelEffect = ppAnimateByAllLevels
.AnimateBackground = msoTrue
End With
End If
End If
End If
End If

Next oSh
Next oSl
 
G

Geoff Cox

For Each oSl In ActivePresentation.Slides

ActiveWindow.View.GotoSlide (oSl.SlideIndex)

Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 129 Then
If oSh.TextFrame.TextRange.Text <> "When finished"
Then
If oSh.AnimationSettings.Animate <> _
ppEffectDissolve Then

wrong! I think the above line is being ignored. Must be wrong?

Cheers

Geoff
 
S

Shyam Pillai

Geoff,
I strongly recommend that you read the Timeline object information and all
it's properties and methods. The AnimationSettings object is not reliable if
you are using PPT 2002 and later. It is only provided for backward
compatibility.


--
Regards,
Shyam Pillai

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

Geoff Cox

Geoff,
I strongly recommend that you read the Timeline object information and all
it's properties and methods. The AnimationSettings object is not reliable if
you are using PPT 2002 and later. It is only provided for backward
compatibility.

Shyam,

Of course - soon forgot that didn't I!

I have tried, and failed, to get a handle on the Timeline object -
would really help me if you could show me how it works here!!

How would following code be changed?

Thanks

Geoff

Dim oSl As Slide

For Each oSl In ActivePresentation.Slides

ActiveWindow.View.GotoSlide (oSl.SlideIndex)

Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 129 Then
If oSh.TextFrame.TextRange.Text <> "When finished" Then

If oSh.AnimationSettings.Animate <> msoTrue Then
oSh.AnimationSettings.EntryEffect = ppEffectDissolve

End If
End If
End If
End If



Next oSh
Next oSl
 
A

Austin Myers

Geoff,

Go to Microsoft's site and search for "vbapp10.chm". I think a little
documentaion would be a huge help for you.



Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia http://www.pfcmedia.com
 
G

Geoff Cox

Geoff,

Go to Microsoft's site and search for "vbapp10.chm". I think a little
documentaion would be a huge help for you.

Austin,

Isn't this going to be the help that comes with PPT 2003? If so it is
not the easiest of ways to learn about VBA!

Can you suggest any good books?!

Cheers

Geoff
 
G

Geoff Cox

Geoff,
I strongly recommend that you read the Timeline object information and all
it's properties and methods. The AnimationSettings object is not reliable if
you are using PPT 2002 and later. It is only provided for backward
compatibility.

Shyam,

'have made a little progress! Code below adds bounce animation to the
type 132 button - but how do I add a sound effect?

Geoff

Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then

oSl.TimeLine.MainSequence.AddEffect _
Shape:=oSh, EffectId:=msoAnimEffectBounce

End If
End If
 
S

Shyam Pillai

Try:

Dim oEff As Effect

'Add the bounce effect and get a reference to the effect.
Set oEff = oSl.TimeLine.MainSequence.AddEffect(Shape:=oSh, _
EffectId:=msoAnimEffectBounce)
' No attach the sound to the effect.
Call oEff.EffectInformation.SoundEffect _
.ImportFromFile("C:\WINDOWS\media\tada.wav")

This might be useful also to get you started:

Timeline - The animation engine in PowerPoint 2002/2003 - Part I
http://skp.mvps.org/ppttimeline1.htm
--
Regards,
Shyam Pillai

Animation Carbon
http://www.animationcarbon.com
 
G

Geoff Cox

Dim oEff As Effect

'Add the bounce effect and get a reference to the effect.
Set oEff = oSl.TimeLine.MainSequence.AddEffect(Shape:=oSh, _
EffectId:=msoAnimEffectBounce)
' No attach the sound to the effect.
Call oEff.EffectInformation.SoundEffect _
.ImportFromFile("C:\WINDOWS\media\tada.wav")

Thanks Shyam! The code below plays the sound and gives the action
button Entrance/Dissolve animation but removes the other animation on
the slide!!! (words moving from one place to another)

This should not happen with Timeline etc? Where have I gone wrong?

Cheers

Geoff


For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then

Set oEff = oSl.TimeLine.MainSequence.AddEffect(Shape:=oSh, _
EffectId:=msoAnimEffectDissolve)
Call oEff.EffectInformation.SoundEffect _
.ImportFromFile("C:\WINDOWS\media\tada.wav")

End If
End If

Next oSh
Next oSl
 
G

Geoff Cox

On Mon, 9 Oct 2006 19:29:36 -0400, "Shyam Pillai"

Shyam,

'just to say that I have now been able to write the code which finds
an action button with EndShow and adds dissolve animation to it, using
the TimeLine object and the other animation on the slide is not
deleted!

Thanks for your help.

Geoff


Dim oSl As Slide

For Each oSl In ActivePresentation.Slides

Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 132 Then
oSl.TimeLine.MainSequence.AddEffect oSh, _
msoAnimEffectDissolve
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

Similar Threads


Top