本文介绍了从VSTO托管代码在Excel中运行宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发Excel Excel加载项妥协的Excel加载项(.xla
文件)和COM加载项(托管)用Visual Studio Tools编写的C#代码
Office)。 在COM加载项的启动功能中,我需要在.xla文件上调用宏
。
在加载项的安装程序应用程序中,我正在更改Excel安全性中的注册表项
,以便:
- 勾选对VBA项目对象模型的信任访问权限复选框;
- 启用所有宏。
在我测试加载项的大部分计算机上,所有
都能正常工作。 但是有一些计算机(当试图运行
宏时)失败并出现以下错误:
"无法运行宏'XXXXX'。 宏可能在此
工作簿中不可用,或者可能禁用所有宏。
我假设在Excel 2007中必须进行一些进一步的配置,以允许
运行宏。 任何指导我正确方向的帮助都是
非常感谢。我已经尝试在Excel编程论坛上发布此问题,但没有运气。
分类解决方案
I am developing an Excel 2007 add-in compromising of an Excel Add-In (.xla file) and a COM Add-In (managed code written in C# in Visual Studio Tools For Office). In the start-up function of the COM Add-In I need to call a macro on the .xla file. In the installer application for the add-in I am changing the registry keys in Excel Security so that: - The Trust access to VBA project object model check box is ticked; - All macros are enabled. On a large proportion of computers that I test the add-in on, everything works fine. However there are a few computers which (when attempting to run the macro) fails with the following error: "Cannot run the macro 'XXXXX'. The macro may not be available in this workbook or all macros may be disabled." I assume that there must be some further configuation in Excel 2007 to allow the macro to be run. Any help in pointing me in the right direction would be greatly appreciated. I have already tried posting this problem on the Excel-Programming forum but with no luck.解决方案
这篇关于从VSTO托管代码在Excel中运行宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!