Vba 在Powerpoint中切换按钮
我试图在powerpoint的几个页面中插入切换按钮。我已经有了按我所希望的方式行事的按钮,但现在我看不到要做两件事: 运行程序!!!我删除了所有内容,从零开始,除了我的第一个代码(见下文),没有编写任何其他内容。我需要什么来修复它。当我点击连接到YourName()的形状时,什么都没有发生 B.我想在开始时将按钮的值设置为0。一旦运行,您认为我的代码会这样做吗 谢谢Vba 在Powerpoint中切换按钮,vba,button,toggle,powerpoint,Vba,Button,Toggle,Powerpoint,我试图在powerpoint的几个页面中插入切换按钮。我已经有了按我所希望的方式行事的按钮,但现在我看不到要做两件事: 运行程序!!!我删除了所有内容,从零开始,除了我的第一个代码(见下文),没有编写任何其他内容。我需要什么来修复它。当我点击连接到YourName()的形状时,什么都没有发生 B.我想在开始时将按钮的值设置为0。一旦运行,您认为我的代码会这样做吗 谢谢 Sub YourName() Dim userName As String Dim ToggleButton1 As Toggl
Sub YourName()
Dim userName As String
Dim ToggleButton1 As ToggleButton
Dim ToggleButton2 As ToggleButton
Dim ToggleButton3 As ToggleButton
Dim ToggleButton4 As ToggleButton
Dim done As Boolean
done = False
While Not done
userName = InputBox(Prompt:="My name is", Title:="Input Name")
If userName = "" Then
done = False
Else
done = True
End If
Wend
FeedbackAnswered = False
ActivePresentation.Slides(2).ToggleButton("ToggleButton1").Value = 0
ActivePresentation.Slides(2).ToggleButton("ToggleButton2").Value = 0
ActivePresentation.Slides(2).ToggleButton("ToggleButton3").Value = 0
ActivePresentation.Slides(2).ToggleButton("ToggleButton4").Value = 0
ActivePresentation.SlideShowWindow.View.Next
End Sub
您的代码无法编译(打开IDE,打开代码所在的模块,选择调试|编译)。当您尝试在幻灯片放映中运行损坏的代码时(就像您正在做的那样),PPT不会发出任何错误消息,它只是根本不会尝试运行代码
这至少可以编译;我没有时间用正确的形状创建演示文稿,但嘿,我不得不给你留下一些乐趣:
Option Explicit
Sub YourName()
Dim userName As String
' Dim these as Object; there's no such thing as ToggleButton
Dim ToggleButton1 As Object
Dim ToggleButton2 As Object
Dim ToggleButton3 As Object
Dim ToggleButton4 As Object
Dim done As Boolean
' You forgot one:
Dim FeedbackAnswered As Boolean
done = False
While Not done
userName = InputBox(Prompt:="My name is", Title:="Input Name")
If userName = "" Then
done = False
'您可能需要在此处添加一个出口接头,否则将导致穷人
“用户没有出路
Else
done = True
End If
Wend
FeedbackAnswered = False
' Fixed these too:
ActivePresentation.Slides(2).Shapes("ToggleButton1").OLEFormat.Object.Value = 0
ActivePresentation.Slides(2).Shapes("ToggleButton2").OLEFormat.Object.Value = 0
ActivePresentation.Slides(2).Shapes("ToggleButton3").OLEFormat.Object.Value = 0
ActivePresentation.Slides(2).Shapes("ToggleButton4").OLEFormat.Object.Value = 0
ActivePresentation.SlideShowWindow.View.Next
End Sub