简体   繁体   English

使用VBA在功能区上执行加载项元素

[英]Executing Add-in element on the ribbon with VBA

I have an excel COM add-in that have quick access toolbar with element that i can execute by clicking on it. 我有一个Excel COM加载项,该加载项具有快速访问工具栏,该工具栏具有可以通过单击执行的元素。 Right now I want to write VBA macro that executes this element multiple times. 现在,我想编写多次执行此元素的VBA宏。 I am trying to get to this add-in elements with this lines: 我正在尝试使用以下代码来访问此加载项元素:

Dim addinModule As Object Set addinModule = Application.COMAddIns.Item("MyExcelAddin").Object But all I can get is error that says "Run-time Error 9: Subscript out of range" Dim addinModule As Object Set addinModule = Application.COMAddIns.Item("MyExcelAddin").Object但是我能得到的只是说“运行时错误9:下标超出范围”的错误。

I can't add it in tools-> references, in COM-Addins section in developer mode it is loaded. 我无法在工具->引用中添加它,在开发人员模式下的COM-Addins部分中已加载它。

Regards 问候

You have to use the progID not the description . 您必须使用progID而不是description

For a list of all the COM add-ins running just run: 有关正在运行的所有COM加载项的列表,请运行:

Dim i As Long
For i = 1 To Application.COMAddIns.Count
    With Application.COMAddIns(i)
        Debug.Print .progID & "  :  " & .Description
    End With
Next

If it's loaded, you should see it in the list. 如果已加载,则应在列表中看到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM