Excel Startup Problems

RazerWriter

Active member
Joined
Jun 26, 2003
Messages
32
"server has thrown an exception" at this line of code:
exExcel.Workbooks.Open(strFilename)

what the heck is wrong!!!
 
Are you positive the filename exists? Perhaps you should post some more related code.
 
Dim exExcel As New Excel.Application
Dim exSheet As Excel.Worksheet

exExcel.Workbooks.Open(strFilename)


yes, the file exists, i have even tried "c:\test.xls". I am using the Excel 8.0 Objects Library

[edit]Dont start multiple threads on the same question[/edit]
 
im using 10.0 but this may help , i think you should try setting the excel sheet as the item thats opening the app , like this :
Code:
    Dim exExcel As New Excel.Application()
    Dim exSheet As Excel.Workbook

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        exSheet = exExcel.Workbooks.Open("C:\Book1.xls")
        MsgBox(exSheet.Sheets.Count) ///just to check the excel app did open
    End Sub
 
------------------------------------
Option Strict Off

Public Class xlManager

Public Shared xlApp As Object
Public Shared xlBook As Object
Public Shared xlSheet As Object



End Class
 
------------------------------------
Option Strict Off

Public Class xlManager

Public Shared xlApp As Object
Public Shared xlBook As Object
Public Shared xlSheet As Object

sub

xlApp = CreateObject("Excel.Application")
Late bind an instance of an Excel workbook.
xlBook = xlApp.Workbooks.Add
Late bind an instance of an Excel worksheet.
xlSheet = xlBook.Worksheets(1)
xlSheet.Activate()

xlBook.SaveAs(strFilename)

end sub

End Class

------------------------------------

Apparently VB NET has a feature called "late-binding". Somehow that code made it work! Strange. Well, I had to go through tons of msdn articles to get it. Thank God it works and I can go on with my life :)
 
Back
Top