zoukankan      html  css  js  c++  java
  • Windows server 2008 64bit计划任务运行使用了excel 2003 32bit .net开发组件的程序遇到的问题

    代码:

    View Code
     1             try
     2             {
     3                 excelApplication = new Excel.ApplicationClass();
     4                 excelWorkBooks = excelApplication.Workbooks;
     5                 excelWorkBook = ((Excel.Workbook)excelWorkBooks.Open(excelOpenFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
     6                 excelWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets[excelActiveWorkSheetIndex];
     7                 excelApplication.Visible = false;
     8 
     9                 return true;
    10             }
    11             catch (Exception e)
    12             {
    13                 CloseExcelApplication();
    14                 MessageBox.Show("(1)没有安装Excel 2003;(2)或没有安装Excel 2003 .NET 可编程性支持;\n详细信息:"
    15                     +e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    16                 //throw new Exception(e.Message);
    17                 LabMessage.Text = "(1)没有安装Excel 2003;(2)或没有安装Excel 2003 .NET 可编程性支持;\n详细信息:"+ e.Message;
    18                 return false;
    19             }
     

    问题:

    Windows server 2008 64-bit计划任务运行使用了excel 2003 32-bit .net开发组件的程序,打开excel2003,报错

    System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

    通过跟踪代码,发现是第3行,new ApplicationClass()对象时报错

    解决办法:

    On 64 bit system with 32 bit Office try this:

    1.         Start

    2.         Run

    3.         mmc -32

    4.         4.File

    5.         Add Remove Snap-in

    6.         Component Services

    7.         Add

    8.         OK

    9.         Console Root

    10.     Component Services

    11.     Computers

    12.     My Computer

    13.     DCOM Config

    14.     Microsoft Excel Application

    15.     右键打开属性对话框

    16.     点击"安全"选项卡,

    18.     "启动和激活权限","配置权限",都选择为自定义,

    19.     然后依次点击它们的编辑,把计划任务执行用的账号添加进去,并加入所有的权限...

    如果以上解决办法无效,再试试下面的:

     运行dcomcnfg打开组件服务

     依次展开"组件服务"->"计算机"->"我的电脑"->"DCOM配置"

     找到"Microsoft Excel应用程序"

     右键打开属性对话框,点击"标识"选项卡,依次选择The interactive user或者This user试试。

    如果还不行,看看执行计划任务的账户是否在administrator群组中,如没有,请加入administrator群组再测试一下。

  • 相关阅读:
    组合博弈入门
    模拟练1
    鼠标点击 input,显示瞬间的边框颜色,对之修改与隐藏
    display: inline-block兼容性写法
    background-clip与background-origin两者的区别
    article标签和aside标签两者的理解
    jQuery插件实现左右无缝轮播
    JS面向对象基础2
    JS面向对象基础1
    CSS3的基础知识点
  • 原文地址:https://www.cnblogs.com/thomaswang/p/2323323.html
Copyright © 2011-2022 走看看