Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching Excel From VB.net

Status
Not open for further replies.

Viruland

Programmer
Dec 6, 2000
61
BE
I'm trying to open Excel from my VB.net application and I always get the following Error Message:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Office.exe

Additional information: Old format or invalid type library.

I've added the Microsoft Excel 9.0 Object library reference and the Microsoft Office 9.0 Object library refernce to my project.

I'm using the following code:

Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
Dim excelWorksheet As Excel.Worksheet = _
CType(excelBook.Worksheets(1), Excel.Worksheet)
excelApp.Visible = true



Live fast, die young and leave a beautiful corpse behind.
 
Add this code

Code:
        'Declare the excelApp object
        Dim excelApp as New Excel.Application

        'Create the application object
        try
            excelApp = CreateObject("Excel.Application")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

Now you can add workbooks.
 
Fawkes,

I've already try that but I still get the same error.

Live fast, die young and leave a beautiful corpse behind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top