Formula for a motion path

A

Alon Amit

Is it possible to use VB to create a motion path (for an animated
object) from a mathematical formula, or from an imported list of
coordinates?

In more detail: I'd like to be able to animate an object so that it
follows the graph of some function. Obviously I'm not thinking of any
of the custom paths that can be found under "More motion paths", and
I'm also not looking at bezier curves which I think is what "Curve"
under "Draw Custom Path" does.

Since it is possible to freely draw a path, there doesn't seem to be an
inherent limitation on the path's structure. However, there's no way to
input a formula, and I also couldn't see how to import a list of
coordinates and use them to create the path. So I guess the question
is: is the internal representation of path coordinates accessible to
VBA modules?

A more fundamental question would be: is it, in general, possible to
inspect the internal representation of an object, and modify it? How
can one tell which features of an object are modifiable by VB code and
which aren't?

Thanks!

Alon
 
S

Steve Rindsberg

A more fundamental question would be: is it, in general, possible to
inspect the internal representation of an object, and modify it? How
can one tell which features of an object are modifiable by VB code and
which aren't?

It's much simpler to work this out in the VBA IDE than from VB.

Select a shape in PPT, switch to the IDE, add a new module and type:

Sub Test()
With ActiveWindow.Selection.ShapeRange(1)
' that gives you a reference to the currently selected shape
' with that you can do:

Debug.Print .
' and as soon as you type the period, you get a popup list of
' properties and methods that apply to the shape

End With
End Sub
 
A

Alon Amit

Thanks, this is very useful. It seems that the popup list does contain
properties that the selected object does not support; for instance, a
simple autoshape contains "AnimationSettings" in the popup list, but
when I try to run the macro I get an error message - "Object does not
support this property ot method".

Anyway, I'm afraid I still couldn't figure out if motion path
coordinats are accessible. I tried recording a macro in which I'm
creating a motion path; unfortunately, the macro records nothing. Does
this mean that animation cannot be created or modified from a macro?
Thanks again,

Alon
 
A

Alon Amit

Thanks Steve, this is very useful.

I did notice that some properties and methods that appear on the menu
after I type the period aren't really available for that object. For
instance, "AnimationSettings" appears for a simple Autoshape object,
but when I try to actually run the macro I get an error message.

Anyway, I'm still not sure if motion paths are visible to VBA. When I
tried to record a macro in which I created and edited motion paths in
an attempt to see what the objects' names are, the macro recorded
nothing :-( . Does this mean that VBA cannot create or modify a motion
path?

Thanks again,

Alon
 
G

Guest

(Sorry for the double posting. For some reason my replies don't show up on
Google Groups).
 
S

Steve Rindsberg

Alon Amit said:
Thanks, this is very useful. It seems that the popup list does contain
properties that the selected object does not support; for instance, a
simple autoshape contains "AnimationSettings" in the popup list, but
when I try to run the macro I get an error message - "Object does not
support this property ot method".

That wasn't really meant to be run, just to show the popup.

It gives you an error at that point because animation settings is a collection,
not a printable property.

If you let it fill in .AnimationSettings then type another dot (.) you'll see
the animation settings properties.
Anyway, I'm afraid I still couldn't figure out if motion path
coordinats are accessible. I tried recording a macro in which I'm
creating a motion path; unfortunately, the macro records nothing. Does
this mean that animation cannot be created or modified from a macro?

Not necessarily; the macro recorder isn't able to record everything you can do
in PowerPoint, including quite a few things that you *can* do in VBA.

Of course, the fact that I know that doesn't mean that I necessarily know how
to solve your problem. Trying to learn some of this end of PPT myself in fact.

Check here and look around a bit. AJ did some nice articles on PPT's animation.

http://blogs.msdn.com/andrew_may/
 
A

Alon Amit

Thanks Steve, this is very useful.

I did notice that some properties and methods that appear on the menu
after I type the period aren't really available for that object. For
instance, "AnimationSettings" appears for a simple Autoshape object,
but when I try to actually run the macro I get an error message.

Anyway, I'm still not sure if motion paths are visible to VBA. When I
tried to record a macro in which I created and edited motion paths in
an attempt to see what the objects' names are, the macro recorded
nothing :-( . Does this mean that VBA cannot create or modify a motion
path?

Thanks again,

Alon
 
A

Alon Amit

Thanks again - this is really helpful! I'm getting closer...

Through Andrew May's text I found my way here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbapp10/html/ppobjMotionEffect.asp

This page has an example code that adds a star shape to the current
slide, and makes it animated with a custom path. If I could stack the
ToX and ToY properties and create an elaborate path - I've solved my
problem.

However, the code doesn't seem to work for me as is (I'm currently
using PowerPoint 2002 SP3). The object gets created OK and has custom
animation properties, but when I try to play the animation (either in
Slide Show mode or using the Play button on the Custom Animation pane),
the star just vanishes. This is strange.

The animation properties of the star created by the code are different
from those of an object I create manually. In the latter case, you see
a dashed line representing the path (with the green and red arrows at
the beginning and end points), and the animation type is called "Custom
Path". With the star, I see no path, and the animation type is just
"Custom". This is probably due to the msoAnimEffectCustom that's used
in the code, but I couldn't see that there is any
msoAnimEffectCustomPath alternative, so I guess this is actually the
one that should be used (I couldn't exactly figure it out from the MSDN
reference manual).
Any thoughts would be greatly appreciated - this is so close...

Alon
 
S

Steve Rindsberg

Alon Amit said:
Thanks again - this is really helpful! I'm getting closer...

Through Andrew May's text I found my way here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbapp10/html/p
pobjMotionEffect.asp

This page has an example code that adds a star shape to the current
slide, and makes it animated with a custom path. If I could stack the
ToX and ToY properties and create an elaborate path - I've solved my
problem.

However, the code doesn't seem to work for me as is (I'm currently
using PowerPoint 2002 SP3). The object gets created OK and has custom
animation properties, but when I try to play the animation (either in
Slide Show mode or using the Play button on the Custom Animation pane),
the star just vanishes. This is strange.

If it's any comfort, the same thing happens here and I see no motion path on
the star.
The animation properties of the star created by the code are different
from those of an object I create manually. In the latter case, you see
a dashed line representing the path (with the green and red arrows at
the beginning and end points), and the animation type is called "Custom
Path". With the star, I see no path, and the animation type is just
"Custom". This is probably due to the msoAnimEffectCustom that's used
in the code, but I couldn't see that there is any
msoAnimEffectCustomPath alternative, so I guess this is actually the
one that should be used (I couldn't exactly figure it out from the MSDN
reference manual).
Any thoughts would be greatly appreciated - this is so close...

Any thoughts I had right now would be of horizonatal stasis. Me. Bed.
I'll have a look in the AM though.
 
A

Alon Amit

Me should Bed also, but want to get animation work...

Shyam Pillai has a better version of this code, which *does* work,
here:

http://www.mcse.ms/message637367.html

He is correcting someone else's code which I had to tweak at some
points; for instance there are no "Set" commands and the m_objPpt
prefix seems not to agree with my version of the compiler. I'm not sure
what this is - an older version of the syntax?

Anyway, the object is now animated. The motion path still doesn't show,
and Pillai signs off with the following message:

"Another suggestion is: Instead of using the FromX, FromY, ToX and ToY
properties, create a VML motion path string and assign it to the Path
property. The major benefit is that then the user can edit the path in
the
UI."

Well, I'd love to do that, only I've no idea what a VML string is, what
syntax I should use for the path, and how to assign it to the Path
property. One possibly relevant entry in the manual is here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbapp11/html/ppproPath1.asp

Quite unbelievably, this page seems to mix references to *directory*
paths and *motion* paths(!). Anyway, there's not a word on how to
actually use the string for a motion path.

Just thought I'd help you make an interesting morning. Thanks again!
Alon
 
S

Steve Rindsberg

Alon,

I've had another brief look but haven't figured out why it doesnt' work.

I know if Shyam were back, he'd be able to tell you in an instant.
Ah, Romance. It's lovely but it has no place in a NEWSGROUP. <g>

And I'm going to be a bit scarce from here on in, as I'm standing in as father of
the groom at another wedding in a day or two. The Boss says I'm needed
elsewhere. <g>
 

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