从VSTO托管代码在Excel中运行宏 [英] Runing a macro in Excel from VSTO managed Code

查看:327
本文介绍了从VSTO托管代码在Excel中运行宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Excel Excel加载项妥协的Excel加载项(.xla 
文件)和COM加载项(托管)用Visual Studio Tools编写的C#代码
Office)。 在COM加载项的启动功能中,我需要在.xla文件上调用宏


在加载项的安装程序应用程序中,我正在更改Excel安全性中的注册表项
,以便:
- 勾选对VBA项目对象模型的信任访问权限复选框;
- 启用所有宏。
在我测试加载项的大部分计算机上,所有
都能正常工作。 但是有一些计算机(当试图运行
宏时)失败并出现以下错误:

"无法运行宏'XXXXX'。 宏可能在此
工作簿中不可用,或者可能禁用所有宏。

我假设在Excel 2007中必须进行一些进一步的配置,以允许
运行宏。 任何指导我正确方向的帮助都是
非常感谢。我已经尝试在Excel编程论坛上发布此问题,但没有运气。

分类<= pre>

解决方案

嗨!

我认为"少数计算机"你能看到"By Design"吗?如果注册表项已更改,则由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.


解决方案

Hi!

I that "few computers" can you see "By Design" if the registry keys changed are assumed by excel?
Are you in a Domain Network?
Are you giving the option to install All Users?
When the installer run, by default are all options the same in every computers?


这篇关于从VSTO托管代码在Excel中运行宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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