实现幻灯片之间的跳转的方法及示例代码

376 篇文章 ¥29.90 ¥99.00
本文介绍了四种实现幻灯片之间跳转的方法,包括使用按钮或链接、动画效果、交互式控件和幻灯片导航工具。提供了使用VBA的示例代码,适用于Microsoft PowerPoint,帮助用户理解如何在不同场景下进行幻灯片跳转操作。

幻灯片之间的跳转是在幻灯片展示或演示过程中常见的需求之一。下面我将介绍几种常用的方法来实现幻灯片之间的跳转,并提供相应的示例代码。

方法一:使用按钮或链接

一种简单的方法是在幻灯片上添加按钮或链接,点击按钮或链接时执行跳转操作。这可以通过在幻灯片中插入形状或文本框,并为其添加超链接或宏来实现。

示例代码:

Sub JumpToSlide()
    SlideShowWindows(1).View.GotoSlide Index:=3
End Sub

上述示例代码是使用VBA(Visual Basic for Applications)编写的。在此示例中,当点击按钮时,跳转到索引为3的幻灯片。

方法二:使用动画效果

另一种方法是利用动画效果来实现幻灯片之间的跳转。您可以通过设置动画效果的触发条件为“点击”并指定跳转目标来实现。

示例代码:

Sub JumpToNextSlide()
    With ActivePresentation.Slides(1).TimeLine.MainSequence.AddEffect(Shape:=ActivePresentation.Slides(1).Shapes(1), effectId:=msoAnimEffectFade)
        .MoveToSlide Index:=2
    End With
End Sub

上述示例代码是使用VBA编写的。在此示例中,当点击幻灯片上的形状时

OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy Useful PowerPoint VBA code snippets More Sharing Services Share | Share on gmail Share on google Share on facebook Share on twitter Determine the current slide in the Slide View mode: Sub SlideIDX() MsgBox "The slide index of the current slide is:" & _ ActiveWindow.View.Slide.SlideIndex End Sub Determine the current slide in Slide Show mode: Sub SlideIDX() MsgBox "The slide index of the current slide is:" & _ ActivePresentation.SlideShowWindow.View.Slide.SlideIndex End Sub Difference between SlideIndex property and SlideNumber property: The SlideIndex property returns the actual position of the slide within the presentation. The SlideNumber property returns the PageNumber which will appear on that slide. This property value is dependent on "Number Slide from" option in the Page Setup. Go to Page Setup and Change the value of "Number Slide from" to 2 and then while on the 1st slide in Slide View run the following Macro Sub Difference() MsgBox "The Slide Number of the current slide is:" & _ ActiveWindow.View.Slide.SlideNumber & _ " while the Slide Index is :" & _ ActiveWindow.View.Slide.SlideIndex End Sub Macro to exit all running slide shows: Sub ExitAllShows() Do While SlideShowWindows.Count > 0 SlideShowWindows(1).View.Exit Loop End Sub Code to refresh current slide during the slide show: Sub RefreshSlide() Dim lSlideIndex As Long lSlideIndex = SlideShowWindows(1).View.CurrentShowPosition SlideShowWindows(1).View.GotoSlide lSlideIndex End Sub Code to reset animation build for the current slide during the slide show: Sub ResetSlideBuilds() Dim lSlideIndex As Long lSlideIndex = SlideShowWindows(1).View.CurrentShowPosition SlideShowWindows(1).View.GotoSlide lSlideIndex, True End Sub Insert a slide after current slide Sub InsertSlide() Dim oView As View With ActivePresentation.Slides Set oView = ActiveWindow.View oView.GotoSlide .Add(oView.Slide.SlideIndex + 1, _ ppLayoutTitleOnly).SlideIndex Set oView = Nothing End With End Sub Copyright 1999-2011 (c) Shyam Pillai. All rights reserved.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值