View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Franco Vitali Franco Vitali is offline
external usenet poster
 
Posts: 1
Default How to Create a Document and Save it from a WinForm

I developed a WinForm application wich takes some
information from a database and I want to write some data
to an .XLS document. When I execute the code it throws an
exception:

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in Excel Test 01.exe

Additional information: Old format or invalid type
library.

My Code:

Microsoft.Office.Interop.Excel.Application ap = new
Microsoft.Office.Interop.Excel.ApplicationClass();

Microsoft.Office.Interop.Excel.Workbook wb =
ap.Workbooks.Add(Type.Missing);

ap.Workbooks.Close();

I need to know how can I start the Application class
properly. Thanks.