问题描述
我的ppt窗口中有一个文本框。
I have a text box in my ppt window.
我启用了开发人员选项标签。
I have enabled developer options tab.
我需要一个VBA代码或类似..
I need a VBA code or something like..
任务是
如果textbox1.text =" abc"然后
If textbox1.text="abc" then
转到下一页或特定页面否
Go to next page or a specific page no
否则
Msgbox"无效输入"
Msgbox"invalid input"
当我在框中输入文字后按下回车键时必须完成此事件。
This event must done when I press enter button after entering text into the box.
提前致谢。
推荐答案
另外,我假设文本框还有其他有效条目,否则为什么不使用按钮。
Also, I presume there are other valid entries for the textbox, otherwise why not use a button.
在显示Microsoft Powerpoint对象的Developer / Visual Basic屏幕中,双击包含"Textbox1"的幻灯片。此代码将更改"abc"的幻灯片。我还添加了另一个条目,以便更好地展示Select Case
语句如何在您不熟悉它时更灵活。
In the Developer/Visual basic screen that shows the Microsoft Powerpoint Objects, double-click the slide that contains the 'Textbox1'. This code will change slides for the "abc" entry and I also added another entry to better show how a Select Case statement might be more flexible for you in case you were unfamiliar with it's use.
Option Explicit
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
On Error Resume Next
If KeyCode.Value = 13 Then
Select Case TextBox1.Text
Case Is = "abc"
PowerPoint.ActivePresentation.SlideShowWindow.View.GotoSlide 4
Case Is = "abcdef"
PowerPoint.ActivePresentation.SlideShowWindow.View.GotoSlide 1
Case Else
MsgBox "invalid input"
End Select
End If
End Sub
您还需要将文件保存为启用宏(通常为.pptm) 。您还会看到这只适用于幻灯片放映(或阅读)模式。
You will also need to save your file as macro-enabled (typically a .pptm). You will also see that this only works in a slide show (or reading) mode.
希望这会让您朝着可行的方向前进。
Hope this gets you headed in a workable direction.
这篇关于PowerPoint TextBox1需要的事件代码。非常简单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!