vba 如何通过注册表启用 Excel 自动化加载项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6309584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I enable an Excel Automation Add-in through the registry?
提问by Frank
I have an Excel Automation Add-in that is registered with COM by my installer. By registering with COM, my add-in appears in the (for Excel 2007) Excel Options > Add-Ins > Manage Excel Add-Ins Go... > Automation list. The users must still navigate to the dialog above and select my add-in to enable it.
我有一个 Excel 自动化加载项,它由我的安装程序注册到 COM。通过向 COM 注册,我的加载项出现在(对于 Excel 2007)Excel 选项 > 加载项 > 管理 Excel 加载项转到... > 自动化列表中。用户仍然必须导航到上面的对话框并选择我的加载项以启用它。
Is it possible (via a registry key perhaps) to enable my automaton add-in programmatically in my installer class (or in VBA) after the types are registered with COM?
在使用 COM 注册类型后,是否可以(可能通过注册表项)在我的安装程序类(或 VBA)中以编程方式启用我的自动机加载项?
Thanks in advance - Frank
提前致谢 - 弗兰克
回答by Hari Seldon
Ive not done ths specifically, but a reference that I use has this to say regarding your question:
我没有专门做过这些,但是我使用的参考资料对您的问题有以下说法:
Automation Add-Ins are loaded in the same way as normal
.xla
Add-Ins , but using the ProgID instead of the file name, as in the following code:
自动化加载项的加载方式与普通加载项相同
.xla
,但使用 ProgID 而不是文件名,如以下代码所示:
Sub installAutomationAddIn()
AddIns.Add Filename:="Excel2007ProgRef.Simple"
AddIns("Excel2007ProgRef.Simple").Installed = True
End Sub
If you are creating an installation routinefor your Add-In, you may want to write directly to the registry in order to set the Automation Add-In as installed. To do so, you need to create the following registry entry (Which will already exist if you've used the above code).
如果您正在为您的加载项创建安装例程,您可能希望直接写入注册表以将自动化加载项设置为已安装。为此,您需要创建以下注册表项(如果您使用了上述代码,则该注册表项已经存在)。
(In the Registry Key:)
HKEY_CURRENT_USER\SOftware\Microsoft\Office.0\Excel\Options
(Create the string value:)
Name = the first unused item in the series: Open, Open1, Open2, etc.
Value = /A "Excel2007ProgRef.Simple"