If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing object
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. |
#2
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing object
Set the repeat until next click.
-- john ATSIGN PPTAlchemy.co.uk Free PPT Hints, Tips and Tutorials http://www.pptalchemy.co.uk/powerpoi...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. |
#3
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing object
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 |
#4
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing object
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...xisting-object |
#5
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing object
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 he 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...xisting-object -- David M. Marcovitz Author of _Powerful PowerPoint for Educators_ http://www.PowerfulPowerPoint.com/ Microsoft PowerPoint MVP Associate Professor, Loyola University Maryland |
#6
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing object
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/powerpoi...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. |
#7
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing obje
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 he 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...xisting-object -- David M. Marcovitz Author of _Powerful PowerPoint for Educators_ http://www.PowerfulPowerPoint.com/ Microsoft PowerPoint MVP Associate Professor, Loyola University Maryland . |
#8
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing obje
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/powerpoi...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. |
#9
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing obje
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 he 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...xisting-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 |
#10
|
|||
|
|||
Please Heeeeelp! Vba code to add animation to an existing obje
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" wrote in message ... 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 he 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...xisting-object -- David M. Marcovitz Author of _Powerful PowerPoint for Educators_ http://www.PowerfulPowerPoint.com/ Microsoft PowerPoint MVP Associate Professor, Loyola University Maryland . |
Thread Tools | |
Display Modes | |
|
|