Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
If you want to set an animation to an existing shape, you have to
identify the shape. This can be done by shape name or number (names tend
to be more stable). For example,
ActivePresentation.Slides(3).Shapes(5)
is a pointer to the 5th shape on slide 3. If you name that shape, then
you could use the name. For example if you named it My Pretty Shape, you
could get to the shape with:
ActivePresentation.Slides(3).Shapes("My Pretty Shape")
Whatever code you have that does something to a slide that is being
added should then work with this. If you post a snippet, we can help you
get it to work properly.
--David
--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
but the spinning is too slow, though it has the exact effect that i need because it lands in a random position of the wheel.
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
> You can assign an animation in PPT
> 2002 and later using the following code:
> Sub CreateAnimation()
> Dim oEffect As Effect
> Dim oShpA As Shape
> With ActivePresentation.Slides(1)
> 'Create two autoshapes on the slide.
> Set oShpA = .Shapes.AddShape(msoShapeRectangle, 100, 100, 50, 50)
> ' Assign an animation to shape A
> Set oEffect = .TimeLine.MainSequence.AddEffect(Shape:=oShpA,
> effectId:=msoAnimEffectAppear)
> End With
> End Sub
>
>
> To assign an interactive animation take a look at the code here:
> http://skp.mvps.org/pptxp012.htm#interactive
>
> You can turn off the animations on the slides but this applies to the
> presentation as a whole and not specific slides. Look at the
> slideshowsetting - ShowWithAnimation property to address this.
>
> To determine the animation status you need to setup an event hook to track
> the animations as they fire. Look on my site for a downloadable example of
> eventhandler in PowerPoint http://skp.mvps.org/download.htm
>
>
> --
> Regards,
> Shyam Pillai
In this example, you already have the shape so you don't need to create
the shapes or assign it to oShpA. You can skip that part of the code and
just use the oShp that you already have.
--David
Do you have a special reason to use vba. It's not necessary to acheive what
you ask
http://www.pptalchemy.co.uk/spin.ppt
--
john ATSIGN PPTAlchemy.co.uk
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
another thing is there a way to make the rotation in this one to go faster?
Sub RndSpin(oShp as Shape)
> > Dim t As Single
> > t = Timer + (Rnd * 4) + 1
> > Do Until Timer> t
> > oShp.Rotation = oShp.Rotation + 5
> > DoEvents
> > Loop
> > End Sub
Thanx thanx thanx !!
"David Marcovitz" wrote:
> .
>
With ActivePresentation.Slides(1)
Set oEffect = .TimeLine.MainSequence.AddEffect(shape:=oShp, effectId:=
msoAnimEffectSpin)
End With
If you haven't already, then you probably need to set oShp to be the
right thing before this:
Set oShp = ActivePresentation.Slides(1).Shapes("Picture 3")
--David
Sub CreateAnimationS()
Dim oEffect As Effect
With ActivePresentation.Slides(1)
Set oEffect =
.TimeLine.MainSequence.AddEffect(Shape:=.Shapes("Picture 3"),
effectId:=msoAnimEffectSpin)
End With
End Sub
Regards,
Shyam Pillai
Image Importer Wizard: http://skp.mvps.org/iiw.htm
"lizsantiago" <lizsa...@discussions.microsoft.com> wrote in message
news:8B97CF01-4786-4AAC...@microsoft.com...
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
"lizsantiago" <lizsa...@discussions.microsoft.com> wrote in message
news:28EEBA1C-02E4-4AB3...@microsoft.com...
> __________ Information from ESET Smart Security, version of virus
> signature database 4995 (20100402) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
__________ Information from ESET Smart Security, version of virus signature database 4995 (20100402) __________
The message was checked by ESET Smart Security.
"liz santiago" wrote:
> .
>
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
Here's the post John referred to, including link:
====
Do you have a special reason to use vba. It's not necessary to acheive what
you ask
http://www.pptalchemy.co.uk/spin.ppt
====
Steve Rindsberg
I don't even spellcheck my own stuff.
John's on his own.
==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/
PPTools add-ins for PowerPoint
http://www.pptools.com/
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
What if we take a different approach. I am imagining two possibilities:
(1) Have one shape and use VBA to adjust the rotation.
(2) Have multiple shapes drawn at different rotations and use VBA to
cycle through which shape is showing at which time.
Either way, you can use generate a random number to decide how many
times to rotate the shape and or cycle through the pictures. It might
not be quite as smooth as an animation, but it shouldn't be too hard and
should do the trick.
--David
I played with this a little bit. I can't get it to go fast, but this
code does the spinning. After this, you just need to check the rotation
of the object to calculate what number it landed on:
Sub Spin()
Dim spinNumber As Long
Dim i As Long
Randomize
spinNumber = 360 * Rnd
For i = 1 To spinNumber
ActivePresentation.Slides(1).Shapes(2).IncrementRotation (1)
'Sleep 1
ActivePresentation.SlideShowWindow.View.GotoSlide 1
Next i
End Sub
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
I started with your code and modified it a wee bit ... for all intents
and purps it's identical, just a bit more generic. This lets me assign
the macro as an action setting on the shape so it acts when clicked on.
Works nicely in 2003 ... haven't tried it in
bugfest^H^H^H^H^H^H^H2007.
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Spin(oSh As Shape)
Dim spinNumber As Long
Dim i As Long
Randomize
spinNumber = 360 * Rnd
For i = 1 To spinNumber
oSh.IncrementRotation (1)
Sleep 1
ActivePresentation.SlideShowWindow.View.GotoSlide
oSh.Parent.SlideIndex
Next i
End Sub
expression.Speed
expression A variable that represents a Timing object.
Example
This example sets the animation for the main sequence to reverse and sets the speed to one second.
Visual Basic for Applications
Sub AnimPoints()
Dim tmlAnim As TimeLine
Dim spdAnim As Timing
Set tmlAnim = ActivePresentation.Slides(1).TimeLine
Set spdAnim = tlnAnim.MainSequence(1).Timing
With spdAnim
.AutoReverse = msoTrue
.Speed = 1
End With
End Sub
Steve, i couldn't make your code work but thanks for all your replies.
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
As in "One second for the whole rotation to occur" or "One second per
iteration of the loop"? (I have to confess, the first time through I plugged
in a way big number for Sleep, forgetting that it might come up randomly with
a really large number of iterations. Task Manager is your Friend.)
One way to make it go a bit faster is to have the increment of the
rotation be 2 (or 3) degrees instead of 1.
--David
---
frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
That's great. It limits the time of rotation instead of the number of
rotations. However, it is mostly the same idea as what we did. I'm
surprised that the screen refreshes to show the rotation. But if it
works, I'm not going to argue with it.
--David