浏览可以分配宏的所有对象 [英] Go through all the objects to which a macro can be assigned

查看:269
本文介绍了浏览可以分配宏的所有对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,在Excel中,我们可以将宏分配给多种对象: shape 表单控件 ActiveX控件 ...

As far as I know, in Excel we can assign macros to several kinds of objects: shape, Form Control, ActiveX Control...

我想编写一个VBA代码来执行以下操作,给定Excel文件:

I would like to write a VBA code to do the following, given an Excel file:


  1. 查看有资格分配给宏的所有现有对象

  2. 对于找到的每个对象,如果分配了一个宏,请打印其名称和宏名称(或理想的身份)。

我想这是穷尽的,有人可以帮忙吗?

I would like this to be exhaustive, could anyone help?

推荐答案

扩展@mehow的答案,位于 ActiveSheet 以下代码将导致形状名称,如果相关联,则为宏名称。

Extending @mehow answer for shapes located in ActiveSheet the following code will result with names of shape and it's macro name if one associated.

Sub getShapeMacro()

    'to secure for unexpected...
    On Error Resume Next

    Dim SHP As Shape
    For Each SHP In ActiveSheet.Shapes
        Debug.Print SHP.Name, SHP.OnAction
    Next

End Sub

这篇关于浏览可以分配宏的所有对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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