vba - 单击时生成 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
解决方案
Sub MsgBoxWhenClicked(oSh As Shape)
If oSh.Name = "Rectangle 13" Then MsgBox "Correct"
End Sub
您可以在 SlideShowMode 期间单击形状运行此子例程。
在普通模式下,选择形状,点击Insert > Action > Mouse Click > Run Macro > MsgBoxWhenClicked
推荐阅读
- c# - 使用 Microsoft Graph 在 Planner 中为当前用户获取所有计划
- angular - Angular 2+ - 自动在所有 ngOnInit 上运行相同的代码
- intellij-idea - IntelliJ 插件与 SDK
- core-data - 如何通过 NSPredicate 间接获取相关对象?
- css - 在整个行/列中对齐网格项目(就像弹性项目一样)
- database-design - 不同版本模型的数据库策略
- android - 活动中的剩余指标
- swift - 带有数值变量的 Swift 函数
- mysql - 在大型数据库中使用 JOIN 进行 MySQL 查询
- php - Laravel 5.6 与 whereHas 的多态关系