Private sub ..... Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Dim range As Excel.Range Dim rCnt As Integer Dim cCnt As Integer Dim Obj As Object xlApp = New Excel.Application xlWorkBook = xlApp.Workbooks.Open(nomFichierExcel) xlWorkSheet = xlWorkBook.Worksheets(1) range = xlWorkSheet.UsedRange For rCnt = 1 To range.Rows.Count For cCnt = 1 To range.Columns.Count Obj = CType(range.Cells(rCnt, cCnt), Excel.Range) MsgBox(Obj.value) 'Obj.value correspond au contenu de ta case Next Next xlWorkBook.Close() xlApp.Quit() releaseObject(xlApp) releaseObject(xlWorkBook) releaseObject(xlWorkSheet) 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
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
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question