【问题标题】:PowerPoint How to Run Macro and Hyperlink at The Same Time?PowerPoint 如何同时运行宏和超链接?
【发布时间】:2020-03-06 14:12:10
【问题描述】:

我正在尝试在 powerpoint 中选择您自己的游戏类型。游戏包括一个点系统,当用户单击一个选项时,我使用宏来完成。我还需要一个超链接以根据选择的选项跳转到正确的幻灯片。

我尝试为每个按钮创建 1 个宏,指定滑动要跳转到的位置,但这变得过于混乱,因为到游戏结束时,会有数百个按钮 = 数百个宏。

Dim numCorrect As Integer
Dim numIncorrect As Integer
Dim userName As String
Dim printableSlideNum As Long 'ADDED
Sub GetStarted()
    Initialize
    ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Initialize()
    numCorrect = 0
    numIncorrect = 0
    ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Right()
    numCorrect = numCorrect + 10
End Sub
Sub Wrong()
    numIncorrect = numIncorrect + 25
End Sub
Sub Feedback()
    MsgBox "You spent " & numCorrect + numIncorrect & " minutes to solve the issue" & vbCr & _
    "Out of the " & numCorrect + numIncorrect & ", you wasted " & numIncorrect & " minutes by choosing the wrong options"
End Sub
Sub JumpTo(lSlideIndex As Long)
    SlideShowWindows(1).View.GotoSlide (lSlideIndex)
End Sub
Sub ONEA()
    Right
    JumpTo 6
End Sub

我有一个想法,想创建一个宏,根据形状名称跳转到幻灯片编号,但不知道是否可行。

示例:选项 B 跳转到幻灯片 60 形状名称为 60 vba 将匹配形状名称并跳转到幻灯片 60

对此的任何帮助/想法表示赞赏!

注意:我的 VBA 技能基本上为零。

【问题讨论】:

  • 刚刚将我的代码添加到问题中

标签: vba powerpoint


【解决方案1】:

要命名您的形状,请参阅How to name an object within a PowerPoint slide?


Sub JumpToSlide(oShp As Shape)

lSlideIndex = CLng(oShp.Name)
SlideShowWindows(1).View.GotoSlide (lSlideIndex)

End Sub

要将此宏分配给形状,您可以右键单击形状 --> 超链接 --> 运行宏 --> 选择“JumpToSlide”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-03
    • 2016-10-13
    • 1970-01-01
    • 2015-07-23
    • 1970-01-01
    • 2020-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多