Mega Code Archive

 
Categories / C# Tutorial / Windows
 

BindToMoniker Excel

using System; using System.Runtime.InteropServices; using System.Windows.Forms; using Excel; class MainClass {   [STAThread]   static void Main(string[] args)   {     Excel.Workbook MyWorkBook;     Excel.Worksheet MyWorkSheet;     string FileName = @"C:\Mybook.xls";     MyWorkBook = (Excel.Workbook)Marshal.BindToMoniker(FileName);     MyWorkSheet = (Excel.Worksheet)MyWorkBook.ActiveSheet;     System.Windows.Forms.Application.Run();   } }