我正在试着在powerpoint中选择你自己的游戏类型。这个游戏包括一个积分系统,当用户点击一个选项时,我使用了一个宏来实现这个系统。我还需要一个超链接,以跳转到正确的幻灯片,根据所选择的选项。
我试着为每个按钮创建一个宏,指定要跳转到的位置,但这变得太混乱了,因为在游戏结束时,将有数百个按钮=数百个宏。
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技能基本上为零。
发布于 2020-03-07 00:20:56
要为形状命名,请参见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“
https://stackoverflow.com/questions/60565819
复制相似问题