VBA Shape Animate

B

BoomerM3

In a VBA Add-in, I created a shape called 'GT' on each slide of the
presentation. I then added the following code to animate the shape.
However, it is affecting all the objects on each slide - changing most
of them to advance without click.

With oSld.Shapes("GT").AnimationSettings
.EntryEffect = ppEffectFlyFromBottom
.AdvanceMode = ppAdvanceOnTime
.AdvanceTime = 0
.Animate = msoTrue
End With

If this is a 'naming' issue, how can I change only the shape I just
added (the last shape on the slide)?

I'm stuck.

peter
 
B

Brian Reilly, MVP

I'd guess that you aren't setting the reference to the actual slide
correctly. Throw in a msgbox after this statement which is "msgbox
oSld,SlideIndex" and see if you actually have the right slide, Those
are just my thoughts right now, very tired, going to take a nap.

Brian Reilly, MVP (an MVP who does sleep sometimes)
 
B

BoomerM3

Actually, it loops thru the all the slides just fine... it just doesn't
apply the animation to the single object on the slides.

peter
 
B

Brian Reilly, MVP

post the relevant looping code. I still think you are referring to the
wrong shape on the wrong slide and therefore not applying the correct
method to the shape you think you are applying it to.

also try throwing in a mgbox prior to applying the method e.g.
Msgbox activepresentation.slides(x) to check if you are referring to
the right slide.

Brian Reilly, MVP
 
B

BoomerM3

All this is not happening... PowerPoint 2003.
Here's the sub that does the work.

Sub AddGT()
Dim oSlides As Slides
Dim oSld As Slide
On Error GoTo FlagSlidesErr
Set oSlides = ActivePresentation.Slides
For Each oSld In oSlides
' Add a shape
With oSld.Shapes.AddShape(msoShapeRectangle, 660#, 498#, 36#,
28.875)
.Name = "GT"
.Line.Visible = msoFalse
With .TextFrame.TextRange
.Text = ">>"
With .Font
.Name = "Arial"
.Size = 12
.Bold = msoTrue
.Color.RGB = RGB(253, 255, 208)
End With 'font
End With ' text frame
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.Visible = msoFalse
End With 'add shape
'**************THIS IS THE PROBLEM PART ***************
With oSld.Shapes("GT").AnimationSettings
.EntryEffect = ppEffectFlyFromBottom
.TextLevelEffect = ppAnimateByAllLevels
.AnimateBackground = msoTrue
.AdvanceMode = ppAdvanceOnTime
.AdvanceTime = 0
.Animate = msoTrue
End With
Next oSld
MsgBox (">> add is complete ;)")
FlagSlidesErr:
If Err = 70 Then
MsgBox ("Textbox already in place, can't add again")
End
End If
End Sub
 
B

BoomerM3

As I single-step thru the code, it seems that the single line ".Animate
= msoTrue" changes all previous animations in the slide - Even if I
remove the previous 3 lines of code.

Is this a bug? Or something else I don't understand.
 
S

Steve Rindsberg

BoomerM3 said:
In a VBA Add-in, I created a shape called 'GT' on each slide of the
presentation. I then added the following code to animate the shape.
However, it is affecting all the objects on each slide - changing most
of them to advance without click.

With oSld.Shapes("GT").AnimationSettings
.EntryEffect = ppEffectFlyFromBottom
.AdvanceMode = ppAdvanceOnTime
.AdvanceTime = 0
.Animate = msoTrue
End With

If this is a 'naming' issue, how can I change only the shape I just
added (the last shape on the slide)?


I did this, starting with your code and turning it into a full sub. Works fine
here. What version of PPT are you using? And are you certain the other shapes
don't have some sort of animation setting prior to your running this code?

Sub TestThing123()
Dim oSld As Slide

For Each oSld In ActivePresentation.Slides
With oSld.Shapes("GT").AnimationSettings
.EntryEffect = ppEffectFlyFromBottom
.AdvanceMode = ppAdvanceOnTime
.AdvanceTime = 0
.Animate = msoTrue
End With
Next

End Sub
 
B

BoomerM3

Steve,

PPT version 2003. Yes, there are other objects on the slides and they
DO have animation before I run this routine. It seems that the new
animation is NOT applied to the old objects, but it changes 'On Click'
to 'After Previous'. To test further, I changed AdvanceTime to 5. None
of th eother objects picked up the time of 5.

I am trying to apply this sub to 300+ slides and I don't want to do it
manually.

peter
 
A

Austin Myers

Boomer,

I think what you are seeing is the difference between PPT 2000 and the newer
versions. Specifically the newer versions use a "timeline" statement in
conjunction of your "With" statement. Have you looked at the newer Office
SDK about using the timeline control?

Austin Myers
MS PowerPoint MVP Team

PowerPoint Video and PowerPoint Sound Solutions www.pfcmedia.com





BoomerM3 said:
Steve,

PPT version 2003. Yes, there are other objects on the slides and they
DO have animation before I run this routine. It seems that the new
animation is NOT applied to the old objects, but it changes 'On Click'
to 'After Previous'. To test further, I changed AdvanceTime to 5. None
of th eother objects picked up the time of 5.

I am trying to apply this sub to 300+ slides and I don't want to do it
manually.

peter
 
B

BoomerM3

I did read some of Andrew May's notes. But, the examples I have seen
don't seem a lot different from what I have done. And very few examples
seem to exist.

Suggestions?


Austin said:
Boomer,

I think what you are seeing is the difference between PPT 2000 and the newer
versions. Specifically the newer versions use a "timeline" statement in
conjunction of your "With" statement. Have you looked at the newer Office
SDK about using the timeline control?

Austin Myers
MS PowerPoint MVP Team

PowerPoint Video and PowerPoint Sound Solutions www.pfcmedia.com





BoomerM3 said:
Steve,

PPT version 2003. Yes, there are other objects on the slides and they
DO have animation before I run this routine. It seems that the new
animation is NOT applied to the old objects, but it changes 'On Click'
to 'After Previous'. To test further, I changed AdvanceTime to 5. None
of th eother objects picked up the time of 5.

I am trying to apply this sub to 300+ slides and I don't want to do it
manually.

peter
 
A

Austin Myers

I'm sending you some info via email. (Too large to put in the NG.)

Austin Myers
MS PowerPoint MVP Team

PowerPoint Video and PowerPoint Sound Solutions www.pfcmedia.com



BoomerM3 said:
I did read some of Andrew May's notes. But, the examples I have seen
don't seem a lot different from what I have done. And very few examples
seem to exist.

Suggestions?
 

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