Bonjour tout le monde,
Après avoir fait quelques recherches sur le net pour créer un fichier excel, j'ai essayé de passer à la pratique, voici comment je procède :
Mais lorsque j'execute mon code j'obtiens cet erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Dim xlApp As Microsoft.Office.Interop.Excel.Application Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbooks Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheets xlApp = New Microsoft.Office.Interop.Excel.Application xlWorkBook = xlApp.Workbooks(xlApp) xlWorkSheet = xlApp.Worksheets(xlWorkBook) xlWorkSheet.Cells(1, 1) = "test" xlWorkSheet.SaveAs("C:\vbexcel.xlsx") xlWorkBook.Close() xlApp.Quit() releaseObject(xlApp) releaseObject(xlWorkBook) releaseObject(xlWorkSheet) MsgBox("Excel file created , you can find the file c:\") End Sub Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub End Class
Si quelqu'un aurais une petite piste pour m'aider, cela serais sympa.Le type ne correspond pas. (Exception de HRESULT : 0x80020005 (DISP_E_TYPEMISMATCH))
Partager