VSTO Reference

Unanswered VSTO Reference

  • mercredi 10 mai 2006 13:48
     
     
     

    using System;

    using Excel = Microsoft.Office.Interop.Excel;

    using System.Windows.Forms;

    namespace ConsoleApplication

    {

    class Program

    {

    static bool exit = false;

    static void Main(string[] args)

    {

    Excel.Application myExcelApp = new Excel.Application();

    myExcelApp.Visible = true;

    myExcelApp.StatusBar = "Hello World";

    myExcelApp.Workbooks.Add(System.Type.Missing);

    myExcelApp.SheetBeforeDoubleClick +=

    new Excel.AppEvents_SheetBeforeDoubleClickEventHandler(myExcelApp_SheetBeforeDoubleClick);

    while (exit == false)

    System.Windows.Forms.Application.DoEvents();

    }

    static void myExcelApp_SheetBeforeDoubleClick(object sheet, Excel.Range target, ref bool cancel)

    {

    exit = true;

    }

    }

    }

    Error = The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) C:\Documents and Settings\mark\My Documents\Visual Studio 2005\Projects\AutomationOfExcel\AutomationOfExcel\Program.cs 2 25 AutomationOfExcel

    I know I need to add a reference to Excel but in the book there is a COM tab on the Add Reference dialogue but I dont have a COM tab? I have installed the PIA's I'm sure, so what's missing?

Toutes les réponses