Please Heeeeelp! Vba code to add animation to an existing object

  • Follow


I am a teacher trying to make a game using 2007, and i am trying to do two 
things. One is to add an animation like the spin to a picture by clicking on 
a botton, but all the examples i find , add the animations while creating a 
shape so i dont know how to make the animation to an existing picture in my 
slide. the other thing is to stop the animation by clicking on a button. I 
found an example to pause the slide but the problem is that i have other 
animations that are stopped as well and i cant use that. The picture is of a 
wheel with numbers that i want to spin so when i click the stop it stops on a 
 different number of the wheel.  for the spin i  used the animation set to 
..01 speed until slide ends and used the pause botton to stop it and that 
works great to make it stop in a random number but as i said it stops the 
textboxes that should appear with the questions for the students.  any aideas 
on how to use a code to do what i want. i have bought 3 books and read a 
thousand sites, posted in every forum i have found but no one care to answer. 
this is my last resort. 
0
Reply Utf 4/2/2010 1:01:01 AM

Set the repeat until next click.
-- 
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html






"lizsantiago" wrote:

> I am a teacher trying to make a game using 2007, and i am trying to do two 
> things. One is to add an animation like the spin to a picture by clicking on 
> a botton, but all the examples i find , add the animations while creating a 
> shape so i dont know how to make the animation to an existing picture in my 
> slide. the other thing is to stop the animation by clicking on a button. I 
> found an example to pause the slide but the problem is that i have other 
> animations that are stopped as well and i cant use that. The picture is of a 
> wheel with numbers that i want to spin so when i click the stop it stops on a 
>  different number of the wheel.  for the spin i  used the animation set to 
> .01 speed until slide ends and used the pause botton to stop it and that 
> works great to make it stop in a random number but as i said it stops the 
> textboxes that should appear with the questions for the students.  any aideas 
> on how to use a code to do what i want. i have bought 3 books and read a 
> thousand sites, posted in every forum i have found but no one care to answer. 
> this is my last resort. 
0
Reply Utf 4/2/2010 7:10:01 AM


On 4/1/10 9:01 PM, lizsantiago wrote:
> I am a teacher trying to make a game using 2007, and i am trying to do two
> things. One is to add an animation like the spin to a picture by clicking on
> a botton, but all the examples i find , add the animations while creating a
> shape so i dont know how to make the animation to an existing picture in my
> slide. the other thing is to stop the animation by clicking on a button. I
> found an example to pause the slide but the problem is that i have other
> animations that are stopped as well and i cant use that. The picture is of a
> wheel with numbers that i want to spin so when i click the stop it stops on a
>   different number of the wheel.  for the spin i  used the animation set to
> .01 speed until slide ends and used the pause botton to stop it and that
> works great to make it stop in a random number but as i said it stops the
> textboxes that should appear with the questions for the students.  any aideas
> on how to use a code to do what i want. i have bought 3 books and read a
> thousand sites, posted in every forum i have found but no one care to answer.
> this is my last resort.

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
0
Reply David 4/2/2010 2:55:28 PM

Thanks David, I know how to name the object that i am using since i bought your book, which by the way have made me get interested in vba, my real problem is that i dont know how to assign to a shape one of the effects like spin or fade or something like that. For now i am using this 
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 

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. 
 


0
Reply liz 4/2/2010 4:00:24 PM

Great. I'm glad you are learning from the book. Assigning animation with 
VBA is a bit tricky and then using VBA to activate it is trickier still. 
As I was looking for a link to Shyam's site with explanation of this, I 
came across this post by him:

> 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

On 4/2/10 12:00 PM, liz santiago wrote:
> Thanks David, I know how to name the object that i am using since i bought your book, which by the way have made me get interested in vba, my real problem is that i dont know how to assign to a shape one of the effects like spin or fade or something like that. For now i am using this
> 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
>
> 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


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/2/2010 4:41:50 PM

Liz

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






"lizsantiago" wrote:

> I am a teacher trying to make a game using 2007, and i am trying to do two 
> things. One is to add an animation like the spin to a picture by clicking on 
> a botton, but all the examples i find , add the animations while creating a 
> shape so i dont know how to make the animation to an existing picture in my 
> slide. the other thing is to stop the animation by clicking on a button. I 
> found an example to pause the slide but the problem is that i have other 
> animations that are stopped as well and i cant use that. The picture is of a 
> wheel with numbers that i want to spin so when i click the stop it stops on a 
>  different number of the wheel.  for the spin i  used the animation set to 
> .01 speed until slide ends and used the pause botton to stop it and that 
> works great to make it stop in a random number but as i said it stops the 
> textboxes that should appear with the questions for the students.  any aideas 
> on how to use a code to do what i want. i have bought 3 books and read a 
> thousand sites, posted in every forum i have found but no one care to answer. 
> this is my last resort. 
0
Reply Utf 4/2/2010 6:56:17 PM

Thank you again for your time, i am trying this but it doesnt work 
Sub CreateAnimation()
    Dim oEffect As Effect
    
        With ActivePresentation.Slides(1).Shapes("Picture 3")
         Set oEffect = .TimeLine.MainSequence.AddEffect(Shape:="Picture 3", 
effectId:=msoAnimEffectSpin)
 End With
 End Sub
It says method or data member not found while highlitghing  TimeLine. I have 
no idea what is that.

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:

> Great. I'm glad you are learning from the book. Assigning animation with 
> VBA is a bit tricky and then using VBA to activate it is trickier still. 
> As I was looking for a link to Shyam's site with explanation of this, I 
> came across this post by him:
> 
> > 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
> 
> On 4/2/10 12:00 PM, liz santiago wrote:
> > Thanks David, I know how to name the object that i am using since i bought your book, which by the way have made me get interested in vba, my real problem is that i dont know how to assign to a shape one of the effects like spin or fade or something like that. For now i am using this
> > 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
> >
> > 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
> 
> 
> -- 
> David M. Marcovitz
> Author of _Powerful PowerPoint for Educators_
> http://www.PowerfulPowerPoint.com/
> Microsoft PowerPoint MVP
> Associate Professor, Loyola University Maryland
> .
> 
0
Reply Utf 4/2/2010 7:03:01 PM

Well any other suggestion would be appreciated... i think i do need a code 
because what i want is to make a wheel with numbers spins and stops at a 
random place for a game and i dont want to use a long list of animations to 
make it stop at different points that at the end and after playing the game a 
couple of time  with my students they will know what number would come next. 
besides that i want to be able to add animations to shapes that i already 
have and all the examples i have seen (and believe me i have seen thousands) 
they all add the effects while creating the shape like the one posted in 
here, and when i try to apply it to my shapes( pictures) they never work (of 
course i am just learning vba). So if you know a code that i can use to do 
this i will be in debt with you my whole life!! i am a teacher and 90% of my 
class is about games in powerpoint. 

"John Wilson" wrote:

> Liz
> 
> 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
> 
> 
> 
> 
> 
> 
> "lizsantiago" wrote:
> 
> > I am a teacher trying to make a game using 2007, and i am trying to do two 
> > things. One is to add an animation like the spin to a picture by clicking on 
> > a botton, but all the examples i find , add the animations while creating a 
> > shape so i dont know how to make the animation to an existing picture in my 
> > slide. the other thing is to stop the animation by clicking on a button. I 
> > found an example to pause the slide but the problem is that i have other 
> > animations that are stopped as well and i cant use that. The picture is of a 
> > wheel with numbers that i want to spin so when i click the stop it stops on a 
> >  different number of the wheel.  for the spin i  used the animation set to 
> > .01 speed until slide ends and used the pause botton to stop it and that 
> > works great to make it stop in a random number but as i said it stops the 
> > textboxes that should appear with the questions for the students.  any aideas 
> > on how to use a code to do what i want. i have bought 3 books and read a 
> > thousand sites, posted in every forum i have found but no one care to answer. 
> > this is my last resort. 
0
Reply Utf 4/2/2010 7:31:02 PM

That's because the Timeline is part of the Slide, not the Shape. If your 
shape is oShp, then you need something like (I haven't tested this)

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

On 4/2/10 3:03 PM, lizsantiago wrote:
> Thank you again for your time, i am trying this but it doesnt work
> Sub CreateAnimation()
>      Dim oEffect As Effect
>
>          With ActivePresentation.Slides(1).Shapes("Picture 3")
>           Set oEffect = .TimeLine.MainSequence.AddEffect(Shape:="Picture 3",
> effectId:=msoAnimEffectSpin)
>   End With
>   End Sub
> It says method or data member not found while highlitghing  TimeLine. I have
> no idea what is that.
>
> 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:
>
>> Great. I'm glad you are learning from the book. Assigning animation with
>> VBA is a bit tricky and then using VBA to activate it is trickier still.
>> As I was looking for a link to Shyam's site with explanation of this, I
>> came across this post by him:
>>
>>> 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
>>
>> On 4/2/10 12:00 PM, liz santiago wrote:
>>> Thanks David, I know how to name the object that i am using since i bought your book, which by the way have made me get interested in vba, my real problem is that i dont know how to assign to a shape one of the effects like spin or fade or something like that. For now i am using this
>>> 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
>>>
>>> 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
>>
>>
>> --
>> David M. Marcovitz
>> Author of _Powerful PowerPoint for Educators_
>> http://www.PowerfulPowerPoint.com/
>> Microsoft PowerPoint MVP
>> Associate Professor, Loyola University Maryland
>> .
>>


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/2/2010 7:44:50 PM

Look the at required argument types. AddEffect is expecting a shape 
reference and not the name of the shape.

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" <lizsantiago@discussions.microsoft.com> wrote in message 
news:8B97CF01-4786-4AAC-B509-89EE2B239019@microsoft.com...
> Thank you again for your time, i am trying this but it doesnt work
> Sub CreateAnimation()
>    Dim oEffect As Effect
>
>        With ActivePresentation.Slides(1).Shapes("Picture 3")
>         Set oEffect = .TimeLine.MainSequence.AddEffect(Shape:="Picture 3",
> effectId:=msoAnimEffectSpin)
> End With
> End Sub
> It says method or data member not found while highlitghing  TimeLine. I 
> have
> no idea what is that.
>
> 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:
>
>> Great. I'm glad you are learning from the book. Assigning animation with
>> VBA is a bit tricky and then using VBA to activate it is trickier still.
>> As I was looking for a link to Shyam's site with explanation of this, I
>> came across this post by him:
>>
>> > 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
>>
>> On 4/2/10 12:00 PM, liz santiago wrote:
>> > Thanks David, I know how to name the object that i am using since i 
>> > bought your book, which by the way have made me get interested in vba, 
>> > my real problem is that i dont know how to assign to a shape one of the 
>> > effects like spin or fade or something like that. For now i am using 
>> > this
>> > 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
>> >
>> > 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
>>
>>
>> -- 
>> David M. Marcovitz
>> Author of _Powerful PowerPoint for Educators_
>> http://www.PowerfulPowerPoint.com/
>> Microsoft PowerPoint MVP
>> Associate Professor, Loyola University Maryland
>> .
>> 
0
Reply Shyam 4/2/2010 8:08:41 PM

OHHH! that works but just to make the animation not for what i need.. i was looking to make a button to add the macro and when i click on the button the spin started but that code just create the animation the same as do it directly on the animation tab. so let me try again, cuse there has to be away to add an animation to a shape without creating the shape so it's trigger by clicking on another shape.  if not how can i add more speed to the code i posted before that makes the picture rotate?, that works fine but it is too slow. 
0
Reply liz 4/2/2010 10:57:06 PM

Did you look at the example in the link?

"lizsantiago" <lizsantiago@discussions.microsoft.com> wrote in message 
news:28EEBA1C-02E4-4AB3-A241-3D51DE9F1340@microsoft.com...
> Well any other suggestion would be appreciated... i think i do need a code
> because what i want is to make a wheel with numbers spins and stops at a
> random place for a game and i dont want to use a long list of animations 
> to
> make it stop at different points that at the end and after playing the 
> game a
> couple of time  with my students they will know what number would come 
> next.
> besides that i want to be able to add animations to shapes that i already
> have and all the examples i have seen (and believe me i have seen 
> thousands)
> they all add the effects while creating the shape like the one posted in
> here, and when i try to apply it to my shapes( pictures) they never work 
> (of
> course i am just learning vba). So if you know a code that i can use to do
> this i will be in debt with you my whole life!! i am a teacher and 90% of 
> my
> class is about games in powerpoint.
>
> "John Wilson" wrote:
>
>> Liz
>>
>> 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
>>
>>
>>
>>
>>
>>
>> "lizsantiago" wrote:
>>
>> > I am a teacher trying to make a game using 2007, and i am trying to do 
>> > two
>> > things. One is to add an animation like the spin to a picture by 
>> > clicking on
>> > a botton, but all the examples i find , add the animations while 
>> > creating a
>> > shape so i dont know how to make the animation to an existing picture 
>> > in my
>> > slide. the other thing is to stop the animation by clicking on a 
>> > button. I
>> > found an example to pause the slide but the problem is that i have 
>> > other
>> > animations that are stopped as well and i cant use that. The picture is 
>> > of a
>> > wheel with numbers that i want to spin so when i click the stop it 
>> > stops on a
>> >  different number of the wheel.  for the spin i  used the animation set 
>> > to
>> > .01 speed until slide ends and used the pause botton to stop it and 
>> > that
>> > works great to make it stop in a random number but as i said it stops 
>> > the
>> > textboxes that should appear with the questions for the students.  any 
>> > aideas
>> > on how to use a code to do what i want. i have bought 3 books and read 
>> > a
>> > thousand sites, posted in every forum i have found but no one care to 
>> > answer.
>> > this is my last resort.
>
> __________ 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.

http://www.eset.com



0
Reply John 4/3/2010 10:31:38 AM

Liz, you don’t need to create a macro or use VBA to create a spinner that a 
viewer can randomly stop. John’s solution (following his link to find 
“PowerPoint Spinner”) is a very easy and elegant solution.  It’s simply using 
a trigger to initiate and stop the spin of a clipart of a numbered wheel. You 
would want to use triggers to stop the spinning because, as you’ve noted, 
using slide transitions to stop the animation just moves you to the next 
slide. If you're not familiar with creating triggers, on John's link, look 
for Triggers on the left hand side 

"liz santiago" wrote:

> OHHH! that works but just to make the animation not for what i need.. i was looking to make a button to add the macro and when i click on the button the spin started but that code just create the animation the same as do it directly on the animation tab. so let me try again, cuse there has to be away to add an animation to a shape without creating the shape so it's trigger by clicking on another shape.  if not how can i add more speed to the code i posted before that makes the picture rotate?, that works fine but it is too slow. 
> 
> ---
> frmsrcurl: http://msgroups.net/microsoft.public.powerpoint/Please-Heeeeelp-Vba-code-to-add-animation-to-an-existing-object
> .
> 
0
Reply Utf 4/5/2010 8:25:47 PM

john there is so many post that i am kind of lost here, what link? actually i am not even sure if you were the one who asked me if i saw the link. 
0
Reply liz 4/11/2010 2:44:05 PM

In article <OY4euVY2KHA.6048@TK2MSFTNGP06.phx.gbl>, Liz santiago wrote:
> john there is so many post that i am kind of lost here, what link? actually i am not even sure if you were the one who asked me if i saw the link. 

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/


0
Reply Steve 4/11/2010 3:46:09 PM

you wont beleive it but i am still looking to achieve this game, i saw the link which directed me to a spinnner but that is for sell, is that made with animations only? cuse i have try all animations in the panel and cant till find one that stop the wheel in different points randomly, i can only stop it at points set with the rotation degree and that is not random cuse it will only stop at those points and after playing a few time my students will know what comes next, unless i redo all the animations again. 
0
Reply lizsantiago 4/21/2010 10:19:28 PM

On 4/21/10 6:19 PM, lizsantiago wrote:
> you wont beleive it but i am still looking to achieve this game, i saw the link which directed me to a spinnner but that is for sell, is that made with animations only? cuse i have try all animations in the panel and cant till find one that stop the wheel in different points randomly, i can only stop it at points set with the rotation degree and that is not random cuse it will only stop at those points and after playing a few time my students will know what comes next, unless i redo all the animations again.
>
> ---
> 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

-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/22/2010 4:55:45 PM

On 4/22/10 12:55 PM, David Marcovitz wrote:
> On 4/21/10 6:19 PM, lizsantiago wrote:
>> you wont beleive it but i am still looking to achieve this game, i saw
>> the link which directed me to a spinnner but that is for sell, is that
>> made with animations only? cuse i have try all animations in the panel
>> and cant till find one that stop the wheel in different points
>> randomly, i can only stop it at points set with the rotation degree
>> and that is not random cuse it will only stop at those points and
>> after playing a few time my students will know what comes next, unless
>> i redo all the animations again.
>>
>> ---
>> 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


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/22/2010 9:05:05 PM

I will try it tomorrow and post how it went, i want to thank you and all the people here who have been trying to help me. 
0
Reply lizsantiago 4/22/2010 11:08:59 PM

Your PPT 2007 visibility bug or its cousin?

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



==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


0
Reply Steve 4/23/2010 5:48:44 PM

I can't remember if I was trying this in 2003 or 2007 (I think 2003), 
but I was having problems with the speed. It seemed that no matter what 
I did, every rotation would take about a second. I tried Sleep , and 
that just slowed it down more, which is why I dropped it from my code. 
And when I left out the GotoSlide, it wouldn't refresh at all and just 
pause and then randomly show up with something rotated. Initially, I 
imagined this spinning around several times in a few seconds, but I cut 
it down to a maximum rotation of 1 time around so it wouldn't take forever.
--David

On 4/23/10 1:48 PM, Steve Rindsberg wrote:
> Your PPT 2007 visibility bug or its cousin?
>
> 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
>
>
>
> ==============================
> PPT Frequently Asked Questions
> http://www.pptfaq.com/
>
> PPTools add-ins for PowerPoint
> http://www.pptools.com/
>
>


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/23/2010 9:29:44 PM

David, thanks let me tell you that your code works is a pity i cant make it go faster. Do you think this could be mix wioth your code to make it faster 
Returns or sets a Single that represents the speed, in seconds, of the specified animation. Read/write.
Syntax

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. 
0
Reply lizsantiago 4/23/2010 9:59:56 PM

In article <eOPjYwy4KHA.5548@TK2MSFTNGP04.phx.gbl>, David Marcovitz wrote:
> I can't remember if I was trying this in 2003 or 2007 (I think 2003)
> but I was having problems with the speed. It seemed that no matter what 
> I did, every rotation would take about a second. 

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.)


I tried Sleep , and 
> that just slowed it down more, which is why I dropped it from my code. 
> And when I left out the GotoSlide, it wouldn't refresh at all and just 
> pause and then randomly show up with something rotated. Initially, I 
> imagined this spinning around several times in a few seconds, but I cut 
> it down to a maximum rotation of 1 time around so it wouldn't take forever.
> --David
> 
> On 4/23/10 1:48 PM, Steve Rindsberg wrote:
> > Your PPT 2007 visibility bug or its cousin?
> >
> > 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
> >
> >
> >
> > ==============================
> > PPT Frequently Asked Questions
> > http://www.pptfaq.com/
> >
> > PPTools add-ins for PowerPoint
> > http://www.pptools.com/
> >
> >


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


0
Reply Steve 4/24/2010 8:12:26 PM

That was one second per iteration. I figured I would rotate around 10+ 
times at 1 degree increments so that is between 3600 and 3960 
iterations. At about 1/100th of a second per iteration that would mean 
that a spin would take 3 or 4 seconds. As it turned out at 1 second, it 
would take over an hour.
--David

On 4/24/10 4:12 PM, Steve Rindsberg wrote:
> In article<eOPjYwy4KHA.5548@TK2MSFTNGP04.phx.gbl>, David Marcovitz wrote:
>> I can't remember if I was trying this in 2003 or 2007 (I think 2003)
>> but I was having problems with the speed. It seemed that no matter what
>> I did, every rotation would take about a second.
>
> 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.)
>
>
> I tried Sleep , and
>> that just slowed it down more, which is why I dropped it from my code.
>> And when I left out the GotoSlide, it wouldn't refresh at all and just
>> pause and then randomly show up with something rotated. Initially, I
>> imagined this spinning around several times in a few seconds, but I cut
>> it down to a maximum rotation of 1 time around so it wouldn't take forever.
>> --David
>>
>> On 4/23/10 1:48 PM, Steve Rindsberg wrote:
>>> Your PPT 2007 visibility bug or its cousin?
>>>
>>> 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
>>>
>>>
>>>
>>> ==============================
>>> PPT Frequently Asked Questions
>>> http://www.pptfaq.com/
>>>
>>> PPTools add-ins for PowerPoint
>>> http://www.pptools.com/
>>>
>>>
>
>
> ==============================
> PPT Frequently Asked Questions
> http://www.pptfaq.com/
>
> PPTools add-ins for PowerPoint
> http://www.pptools.com/
>
>


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/26/2010 2:51:54 PM

Unfortunately, I don't think that this code mixes with my code. My code 
doesn't use animations. It just rotates the object. The code you put 
here is for real animations. With real animations, you have more control 
over the way it looks, but you have no way of knowing where the spinner 
ends up.

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

On 4/23/10 5:59 PM, lizsantiago wrote:
> David, thanks let me tell you that your code works is a pity i cant make it go faster. Do you think this could be mix wioth your code to make it faster
> Returns or sets a Single that represents the speed, in seconds, of the specified animation. Read/write.
> Syntax
>
> 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


-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/26/2010 2:55:28 PM

I finally found something that makes the effect i was looking and i wanted to posted here just in case anyone else might need it. 
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 
thanks everyone for your help!!!!;>
0
Reply lizsantiago 4/26/2010 6:52:46 PM

On 4/26/10 2:52 PM, lizsantiago wrote:
> I finally found something that makes the effect i was looking and i wanted to posted here just in case anyone else might need it.
> 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
> thanks everyone for your help!!!!;>
>
> ---
> 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

-- 
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
0
Reply David 4/27/2010 1:48:50 PM

26 Replies
1479 Views

(page loaded in 0.085 seconds)


Reply: