PowerPoint TextBox1需要的事件代码。非常简单。 [英] PowerPoint TextBox1 Event code needed. Very simple.

查看:111
本文介绍了PowerPoint TextBox1需要的事件代码。非常简单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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.

提前致谢。

推荐答案

Hi Shekharmine - 附件是一个可以工作的代码片段。通常我会避免使用KeyUp事件,因为每次击键都会被评估。但是,在这种情况下,这是我知道捕获使用Enter键的唯一方法。

Hi Shekharmine -The attached is a code snippet that will work. Normally I avoid the use of a KeyUp event because every keystroke is evaluated. However, in this case, it is the only way I know of to capture the use of the Enter key.

另外,我假设文本框还有其他有效条目,否则为什么不使用按钮。

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需要的事件代码。非常简单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆