简体   繁体   English

PowerPoint 中的分支幻灯片 (VBA)

[英]Branching Slides in PowerPoint (VBA)

I am trying to create a back button but using hyperlinks it simply just takes me to the previous page and ends up in a loop... eg if I have slide 1 which has links to slide 3, 4 & 5 then slide 3 links to 6 & 7. If I'm currently on slide 7 and click back it successfully takes me back to slide 3 but then I want to click back and end up at slide 1 rather than back to slide 7 (hopefully I'm making some sense!).我正在尝试创建一个后退按钮,但使用超链接它只是将我带到上一页并以循环结束......例如,如果我有幻灯片 1,其中包含幻灯片 3、4 和 5 的链接,然后将幻灯片 3 链接到6 & 7. 如果我当前在幻灯片 7 上并单击返回,它会成功将我带回幻灯片 3,但随后我想单击返回并最终在幻灯片 1 而不是返回幻灯片 7(希望我有一些道理!)。

I presume the only way for me to do this is with VBA can anyone give me some advice on best way to create a back button?我认为我这样做的唯一方法是使用 VBA 任何人都可以就创建后退按钮的最佳方式给我一些建议吗? (I'm using PowerPoint 2007) (我使用的是 PowerPoint 2007)

I was struggling with a similar problem today and made a little "breadcrumb"- generator for powerpoint.我今天在一个类似的问题上苦苦挣扎,做了一个小“面包屑”——PowerPoint 生成器。 There is no link feature yet, but you can implement it if you like: Github Project目前还没有链接功能,但如果你愿意,你可以实现它: Github 项目

Essential parts of the code代码的重要部分

 Public Sub breadcrumbs(ByVal count As Integer, ByRef titles() As String)
    Dim cntr As Integer
    Dim content() As String
    Dim margin As Integer
    Dim width As Integer
    '----------------------------

    ' Set Titles
    content = titles
    cntr = 0
    ' Set width
    width = ((Application.ActivePresentation.PageSetup.SlideWidth - (margin * count * 2) - 20) / count) - 50

    ' Loop through all slides
    For Each sld In Application.ActivePresentation.Slides
        ' generate breadcrumb for each title
        For Each con In content
            sld.Shapes.AddShape(1, (50 + (width * cntr)), 15, width, 50).TextFrame.TextRange.Text = con
            cntr = cntr + 1
        Next con
        cntr = 0

    Next sld

End Sub

It sounds like you want a 'breadcrumb trail' of visited slides, instead of a simple back button.听起来您想要访问幻灯片的“面包屑路径”,而不是简单的后退按钮。 Thus you need a way to preserve the trail.因此,您需要一种方法来保留路径。

This could be addressed with a dynamic array.这可以通过动态数组解决。 New browsing would add records to the array.新浏览会将记录添加到数组中。 Your "Next" and "Previous" locations would be found by moving up or down the array.通过向上或向下移动阵列可以找到“下一个”和“上一个”位置。 You'll have some mild logic puzzles.你会遇到一些轻微的逻辑难题。 I hate to refer you a generic resource , but I'm out of specifics and an overview may be helpful.我不想向您推荐通用资源,但我没有具体说明,概述可能会有所帮助。

UPDATE: I've wanted this in the past for MS Access, and thought I'd readily find a snippet solution.更新:我过去曾想在 MS Access 中使用它,并认为我很容易找到一个片段解决方案。 But now I go to search (thinking it will convert over for you easily as well), and I don't find anything.但是现在我去搜索(认为它也会为您轻松转换),但我什么也没找到。 This is surprising because I imagine it would be fun to built.这令人惊讶,因为我认为建造它会很有趣。 Or ... it's harder to build than I anticipate.或者……构建起来比我预期的要困难。

There is a really cumbersome way to do this in PPT directly with no programming.有一种非常麻烦的方法可以直接在 PPT 中做到这一点,无需编程。 You'll need "forward-facing slides" and 2 sets of "backward-facing slides".您需要“前向滑梯”和 2 套“后向滑梯”。 Backwards ones are two types - direct-back and home-back.向后的有两种类型 - 直接返回和家庭返回。 They can all be identical, but make the backward ones hidden (eg instead of "Slide 3" you'll need "Slide 3a" and "Slide 3b" and "Slide 3c".).它们都可以相同,但要隐藏后面的那些(例如,您需要“幻灯片 3a”、“幻灯片 3b”和“幻灯片 3c”,而不是“幻灯片 3”。)。 They are hidden so that when you progress through normally, you won't see them, but when you link to them, they will appear.它们是隐藏的,因此当您正常进行时,您不会看到它们,但是当您链接到它们时,它们会出现。 Your link list on the "a" slides should always point to the "b" slides and your "b" slides will point to the "c" slides. “a”幻灯片上的链接列表应始终指向“b”幻灯片,而“b”幻灯片将指向“c”幻灯片。 Your hyperlinks on "back button" on "a" slides should be "previous slide" and on the "c" slides should be "last slide viewed" and on "h" slides should be "first slide" (use 'action' to set this instead of 'hyperlink'). “a”幻灯片上“后退按钮”上的超链接应为“上一张幻灯片”,“c”幻灯片上的超链接应为“最后一张幻灯片”,“h”幻灯片上的超链接应为“第一张幻灯片”(使用“动作”设置它而不是“超链接”)。

It takes a while to work through, but it can be done.需要一段时间才能完成,但可以完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM