excel.Interop.Workbooks open does not work

281 Views Asked by At

I have just one Excel file work properly, but when I try with any other Excel files, the app gives me this exception.

My code is correct but I think that I missed something somewhere:

Imports Microsoft.Office.Interop
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office

Dim app As Excel.Application

Public EXCEL_CLASSEUR As Excel.Workbook = Nothing
Dim EXCEL_CLASSEUR_Workbooks As Excel.Workbooks = Nothing

Protected Sub BTN_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BTN.Click

    If (FileUpload1.HasFile) Then
        app = New Excel.Application 'Lance une copie invisible d’Excel 
        EXCEL_CLASSEUR = app.Workbooks.Open(FileUpload1.PostedFile.FileName)
    End If

End Sub
0

There are 0 best solutions below