做了个excel插件,在个别机器上加载失败,程序如下:
public void OnStartupComplete(ref System.Array custom)
{
MessageBox.Show("4");
//添加定制工具条
try
{
string caption = "测试插件";
object missing = System.Reflection.Missing.Value; MessageBox.Show("5");
//看看工具条是不是已经存在
toolBar = (Microsoft.Office.Core.CommandBar)ExcelApp.CommandBars.FindControl(Microsoft.Office.Core.MsoBarType.msoBarTypePopup, missing, caption, true);
if (toolBar == null)
{
MessageBox.Show("6");
toolBar = (Microsoft.Office.Core.CommandBar)ExcelApp.CommandBars.Add(caption, Microsoft.Office.Core.MsoBarPosition.msoBarTop, missing, false);
toolBar.Visible = true;
} }
catch (Exception e)
{
MessageBox.Show("添加插件工具条失败,异常信息:" + e.Message, "Tender System");
}}
可是在机器上调试也没有出现什么问题,就是在有些机器上不行,原先我以为与机器环境有关(也不排除此可能),但测试发现没有触发OnStartupComplete,好像是代码问题,因为如果去掉其中的主要代码,就可以触发OnStartupComplete,高手们帮忙看看上面那段代码有什么问题,我看资料上也是这样写的啊,不知为啥就不行
public void OnStartupComplete(ref System.Array custom)
{
MessageBox.Show("4");
//添加定制工具条
try
{
string caption = "测试插件";
object missing = System.Reflection.Missing.Value; MessageBox.Show("5");
//看看工具条是不是已经存在
toolBar = (Microsoft.Office.Core.CommandBar)ExcelApp.CommandBars.FindControl(Microsoft.Office.Core.MsoBarType.msoBarTypePopup, missing, caption, true);
if (toolBar == null)
{
MessageBox.Show("6");
toolBar = (Microsoft.Office.Core.CommandBar)ExcelApp.CommandBars.Add(caption, Microsoft.Office.Core.MsoBarPosition.msoBarTop, missing, false);
toolBar.Visible = true;
} }
catch (Exception e)
{
MessageBox.Show("添加插件工具条失败,异常信息:" + e.Message, "Tender System");
}}
可是在机器上调试也没有出现什么问题,就是在有些机器上不行,原先我以为与机器环境有关(也不排除此可能),但测试发现没有触发OnStartupComplete,好像是代码问题,因为如果去掉其中的主要代码,就可以触发OnStartupComplete,高手们帮忙看看上面那段代码有什么问题,我看资料上也是这样写的啊,不知为啥就不行
解决方案 »
- Entity Framework 4.3 + Oracle, 遇到了一个奇怪的问题, 求帮助
- JIT调试失败,出现以下错误:拒绝访问
- 100分:大家来聊聊b2b的真正概念!,跟者有分
- 请问如何让窗体自动运行最大化?
- ToBase64Transform类和System.Convert.ToBase64String类区别在哪里?
- C#里面 检测磁盘剩余空间的函数是哪个啊
- 关于媒体播放器
- Datagrid 清空,以及统计他的行数
- 谁有提供C#利用outlook发邮件的示例程序和不用outlook需要验证的SMTP服务器(163.com等)邮件发送程序
- Decimal.Round()方法的问题
- 线程资源是如何处理的?
- 二个xml转化成一个xml文件!
toolBar = (Microsoft.Office.Core.CommandBar)ExcelApp.CommandBars.FindControl(Microsoft.Office.Core.MsoBarType.msoBarTypePopup, missing, caption, true);
if (toolBar == null)
{
MessageBox.Show("6");
toolBar = (Microsoft.Office.Core.CommandBar)ExcelApp.CommandBars.Add(caption, Microsoft.Office.Core.MsoBarPosition.msoBarTop, missing, false);
toolBar.Visible = true;
}
2003也分sp1