首页 > 解决方案 > 单击时生成 MsgBox 的文本框事件

问题描述

我想如果我单击一个文本框(形状)并且它在选择窗格中具有名称“矩形 13”,则获取 msgbox“正确的文本框”。

下面是一个代码,写在课堂上。它没有给我任何输出。

Option Explicit
Public WithEvents App As Application
Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
Debug.Print "App_WindowSelectionChange"
With Sel
    If .Type = ppSelectionShapes Then
        If Sel.ShapeRange.Name = "Rectangle 13" Then
            MsgBox "correct textbox"
        End If
    End If
End With
End Sub

标签: vbapowerpoint

解决方案


Sub MsgBoxWhenClicked(oSh As Shape)
If oSh.Name = "Rectangle 13" Then MsgBox "Correct"
End Sub

您可以在 SlideShowMode 期间单击形状运行此子例程。

在普通模式下,选择形状,点击Insert > Action > Mouse Click > Run Macro > MsgBoxWhenClicked


推荐阅读