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
| Imports Microsoft.Office.Interop
Module Module_1
Sub Recuperer_Contenu_Fichier_Excel
Dim objXL As New Microsoft.Office.Interop.Excel.Application
Dim wbXL As Excel.Workbook
Dim wsXL As New Excel.Worksheet
objXL.Visible = True
wbXL = objXL.Workbooks.Open("C:\Chemin_du_Fichier.xls", , True)
'Activation de la feuille
objXL.ActiveWorkbook.Sheets(1).Name = "Nom de la feuille"
wsXL = objXL.Sheets("Nom de la feuille")
wsXL.Activate()
'à partir d'ici vous pouvez récupérer ce que vous voulez
'voici un petit exemple
dim Resultat as string
Resultat = wsXL.Cells(1, 1).Value ' est la valeur de la cellule A1
objXL = Nothing
wbXL = Nothing
wsXL = Nothing
End sub
End Module_1 |
Partager