如何在VBA中识别单击的形状名称 [英] How to identify the clicked shape name in VBA

查看:73
本文介绍了如何在VBA中识别单击的形状名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个excel模板,在该模板中我已经为不同形状的按钮分配了不同的宏.现在,我很难找到要单击的形状,因为我需要在单击该形状后修改该单击形状的属性.在搜索此问题时,我注意到有一种方法可以识别已选择的形状,而我仍然不知道如何获取我单击的形状的名称或是否有引用的方法在VBA中点击了形状?谢谢!

I am trying to create an excel template where I have already assigned different macros to different shape that act as buttons. Now I am having problem of locating which one I have clicked since I need to modify the attributes of the clicked shape after clicking on that shape. While searching on this problem, I have noticed that there is a way to identify which shape has been selected whereas I still doesn't know How to get the name of the shape I have clicked or is there a way to refer to that clicked shape in VBA? Thank you!

推荐答案

您应该可以通过使用 Application.Caller

用法如图所示

 CallingShapeName = ActiveSheet.Shapes(Application.Caller).Name 

 msgbox CallingShapeName

这篇关于如何在VBA中识别单击的形状名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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