Interop.Excel.Run

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michel Walsh

    Interop.Excel.Run

    I got the following error:
    =============
    Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMIS MATCH))
    =============

    when using Interop.Excel.R un. The relevant code is from "Microsoft .Net
    Development for Microsoft Office":

    =============== =============== =
    using System;
    using System.Collecti ons.Generic;
    using System.Componen tModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows. Forms;
    using Excel = Microsoft.Offic e.Interop.Excel ;

    namespace whatever
    {
    public partial class ManagedCallBack : Form
    {
    object missing = System.Reflecti on.Missing.Valu e;
    public ManagedCallBack ()
    {
    InitializeCompo nent();
    }

    private void button1_Click(o bject sender, EventArgs e)
    {
    Excel.Applicati on xl = new
    Microsoft.Offic e.Interop.Excel .Application();
    xl.Visible = true;
    xl.Workbooks.Op en(@"C:\Temp\Ma nagedCallback\M anagedCallback. xls",
    missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing,
    missing, missing);
    xl.Run("CacheMa nagedObject", this, //
    <---------here ---------
    missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing);
    }
    }
    =============== =============== ======

    Excel opens fine, the desired xls file, which has a VBA public sub
    CacheManagedObj ect in on of its standard module. Security is set to low.
    The OS is Vista and Excel 2003 is the target.

    Someone has an idea about what is wrong with my xl.Run( ) ?


    Thanks,
    Vanderghast, Access MVP

Working...