0

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
djv
  • 15,168
  • 7
  • 48
  • 72
  • `the app gives me this exception.` what exception? – djv Feb 02 '22 at 15:45
  • `app.Visible = True`, is that the solution? Also your method of declaring these objects is wrong. See https://stackoverflow.com/q/158706/832052 – djv Feb 02 '22 at 15:47
  • Does this answer your question? [Excel.Interop.workbooks.open com exception](https://stackoverflow.com/questions/70953661/excel-interop-workbooks-open-com-exception) – Tu deschizi eu inchid Feb 02 '22 at 16:37
  • @djv Exception mssg : ( Sory we can't find "file.xlsx" maybe it's renamed or deleted ) – user14333204 Feb 03 '22 at 07:23

0 Answers0