ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 6222|回复: 5

[转帖] 利用VBA在PowerPoint添加自定义动画路径

[复制链接]

TA的精华主题

TA的得分主题

发表于 2013-7-30 16:31 | 显示全部楼层 |阅读模式
利用VBA在PowerPoint添加自定义动画路径
http://ar.newsmth.net/thread-89abc3ebeca4aa-1.html
原创:FinalSoldier (令狐虫),本人做了部分修改。

  1. Sub AddMotionPath3()
  2.     Dim shpNew As Shape
  3.     Dim effNew As Effect
  4.     Dim aniMotion As AnimationBehavior
  5.     Set shpNew = ActivePresentation.Slides(1).Shapes _
  6.         .AddShape(Type:=msoShape5pointStar, Left:=10, _
  7.         Top:=0, Width:=100, Height:=200)
  8.     Set shpNew = ActivePresentation.Slides(1).Shapes(3)
  9.     Set effNew = ActivePresentation.Slides(1).TimeLine.MainSequence _
  10.         .AddEffect(Shape:=shpNew, effectId:=msoAnimEffectCustom, _
  11.         Trigger:=msoAnimTriggerOnPageClick)
  12.     Set aniMotion = effNew.Behaviors.Add(msoAnimTypeMotion)   
  13.   With aniMotion.MotionEffect
  14.       .Path = "M 0 0 L 0.1 0.05 L 0.2 -0.15 L 0.3 -0.05 L 0.4 -0.15 L 0.5 -0.05 L 0.6 -0.15 L 0.7 -0.05 L 0.8 -0.15 L 0.9 -0.05 L 1.0 -0.15 L 0.9 -0.05 L 0.8 -0.15 L 0.7 -0.05 L 0.6 -0.15 L 0.5 -0.05 L 0.4 -0.15 L 0.3 -0.05 L 0.2 -0.15 L 0.1 0.05 "
  15.   End With     
  16. End Sub
复制代码
1.放映时,新增加的形状不可见,只有进行动画时该形状才可见,
2.动作路径不可见,但动作路径是对的。
改的部分:
原作是“.Path = "M 0 0 L 0.17014 0.05157 L 0.27761 -0.15518 L 0.36268 -0.04972 L 0.42987 -0.10338 " ”。
本人是".path=”是现在的。我想让这个图形能来回,当然要是能设置像正弦函数、余弦函数图像曲线、圆曲线、椭圆方程曲线就好了。希望后来者能更好的实现。
感谢原作者。

VBA添加自定义动画路径.zip

9.5 KB, 下载次数: 125

TA的精华主题

TA的得分主题

发表于 2013-8-5 19:54 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
这个。。。。。好难!!

TA的精华主题

TA的得分主题

发表于 2013-8-10 20:35 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2013-8-11 07:32 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
本帖最后由 banjinjiu 于 2013-8-11 07:35 编辑

在Path语法中,大写代表相对位置,小写代表绝对位置。
例如:M 0 0 就意味着从形状的中心位置开始,但是m0 0 就意味着从幻灯片的左上角开始。
类型        语法                                      备注
移动 M        M StartPoint        
直线 L        E EndPoint        
曲线 C        "C ControlPoint1
                ControlPoint2  EndPoint"       三次贝兹曲线
闭合 Z        Z        
结束 E        E        
详见【灰师太】PPT动画大师 #8设置行为和属性行为
http://www.rapidbbs.cn/forum.php?mod=viewthread&tid=46200&extra=page%3D1

TA的精华主题

TA的得分主题

发表于 2013-9-18 22:33 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2023-3-22 10:05 | 显示全部楼层
banjinjiu 发表于 2013-8-11 07:32
在Path语法中,大写代表相对位置,小写代表绝对位置。
例如:M 0 0 就意味着从形状的中心位置开始,但是m0 ...

谢谢你给出的列子。在学习一边官网的示例。

AnimationBehaviors 对象 (PowerPoint) | Microsoft Learn  https://learn.microsoft.com/zh-c ... .animationbehaviors

  1. Sub AnimationObject()
  2.     Dim timeMain As TimeLine
  3.     'Reference the main animation timeline
  4.     Set timeMain = ActivePresentation.Slides(1).TimeLine
  5.     'Add a five-second animated rotation behavior
  6.     'as the first animation in the main animation sequence
  7.     timeMain.MainSequence(1).Behaviors.Add Type:=msoAnimTypeRotation, Index:=1
  8. End Sub
复制代码
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-25 16:33 , Processed in 0.043241 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表