Vous êtes sur la page 1sur 3

Id_ouvrage

Nom_ouvrage
commune
Quartier
X
Y
Z
Type
Etat
Profondeur
Niveau_statique
Aquifère
Eau_domestique
Eau_commercial
Utilisation_reservoir
Volume_stockage
Date_réalisation
Propriétère
Bénéficiaire
Projet_réalisation
Latrines_proches
Distance_latrines
Analyse_chimique
Couleur_eau
Conductivité
Teneur_nitrates
Eau_goût
Laboratoire
Date_prélèvement
Turbidité

L'eau à un goût, Laboratoire, Date de prélèvement, Turbidité

Projet de réalisadtion

Bénéficiare

Dim boite As FileDialog: Dim chemin As String


Dim instanceE As Excel.Application
Dim base As Database: Dim requete As String
Dim ligne As Long: Dim nbliignes As Long
Dim Id_ouvrage As String: Dim Nom_ouvrage As String: Dim commune As String: Dim
Quartier As String: Dim X As Integer: Dim Y As Integer: Dim Z As Integer: Dim
type_ouvrage As String: Dim Etat As String: Dim Profondeur As Integer: Dim
Niveau_statique As Integer: Dim Aquifère As String: Dim Eau_domestique As Boolean:
Dim Eau_commercial As Boolean: Dim Volume_stockage As Integer: Dim Date_réalisation
As Date: Dim Propriétère As String: Dim Bénéficiaire As String: Dim
Projet_réalisation As String: Dim Latrines_proches As Boolean: Dim
Distance_latrines As Integer: Dim Analyse_chimique As Boolean: Dim Couleur_eau As
String: Dim Conductivité As Integer: Dim Teneur_nitrates As Integer: Dim Eau_goût
As Boolean: Dim Laboratoire As String: Dim Date_prélèvement As Date: Dim Turbidité
As Boolean
Set boite = Application.FileDialog(msoFileDialogFolderPicker)
If boite.Show Then chemin = boite.SelectedItems(1)

If chemin <> "" Then


Set instanceE = creatObject("Excel.Application")
instanceE.Visible = False
instanceE.Workbooks.Open chemin

nbLignes = instanceE.Sheets(1).Cells.SpecialCells(xlCellTypeLastCell).Row
Set base = CurrentDb()
ligne = 2

While instanceE.Sheets(1).Cells(ligne, 2).Value <> ""


With instanceE.Sheets(1)
Id_ouvrage = .Cells(ligne, 2).Value
Nom_ouvrage = .Cells(ligne, 3).Value
commune = .Cells(ligne, 4).Value
Quartier = .Cells(ligne, 5).Value
X = .Cells(ligne, 6).Value
Y = .Cells(ligne, 7).Value
Z = .Cells(ligne, 8).Value
type_ouvrage = .Cells(ligne, 9).Value
Etat = .Cells(ligne, 10).Value
Profondeur = .Cells(ligne, 11).Value
Niveau_statique = .Cells(ligne, 12).Value
Aquifère = .Cells(ligne, 13).Value
Eau_domestique = .Cells(ligne, 14).Value
Eau_commercial = .Cells(ligne, 15).Value
Utilisation_reservoir = .Cells(ligne, 16).Value
Volume_stockage = .Cells(ligne, 17).Value
Date_réalisation = .Cells(ligne, 18).Value
Propriétère = .Cells(ligne, 19).Value
Bénéficiaire = .Cells(ligne, 20).Value
Projet_réalisation = .Cells(ligne, 21).Value
Latrines_proches = .Cells(ligne, 22).Value
Distance_latrines = .Cells(ligne, 23).Value
Analyse_chimique = .Cells(ligne, 24).Value
Couleur_eau = .Cells(ligne, 25).Value
Conductivité = .Cells(ligne, 26).Value
Teneur_nitrates = .Cells(ligne, 27).Value
Eau_goût .Cells(ligne, 28).Value
Laboratoire = .Cells(ligne, 29).Value
Date_prélèvement = .Cells(ligne, 30).Value
Turbidité = .Cells(ligne, 31).Value

requete = "INSERT INTO ouvrages ( ID de l'ouvrage, Nom de l'ouvrage,


Commune, Quartier, X, Y, Z, Types, Etat, Profondeur, Niveau statique, Aquifère, Eau
domestique, Eau commerciale, Utilisation d'un réservoir, Volume de stockage, Date
de réalisation, Propriétère, Bénéficiare, Projet de réalisadtion, Latrine à côté,
Distance des latrines, Analyse chimique, Couleur de l'eau, Conductivité) VALUES ('"
& Id_ouvrage & "', '" & Nom_ouvrage & "','" & commune & "', '" & Quartier & "', '"
& X & "','" & Y & "', '" & Z & "', '" & type_ouvrage & "', '" & Etat & "', '" &
Profondeur & "', '" & Niveau_statique & "', '" & Aquifère & "', '" & Eau_domestique
& "', '" & Eau_commercial & "', '" & Utilisation_reservoir & "', '" &
Volume_stockage & "', '" & Date_réalisation & "', '" & Propriétère & "', '" &
Bénéficiaire & "', '" & Projet_réalisation & "', '" & Latrines_proches & "', '" &
Distance_latrines & "', '" & Analyse_chimique & "', '" & Couleur_eau & "', '" &
Conductivité & "')"
base.Execute requete

evolution.Value = Int((ligne * 100) / nbLignes)

ligne = ligne + 1
End With
Wend
instanceE.Quit
Set instanceE = Nothing
base.Close
Set base = Nothing
End If

MsgBox "L'importation des données Excel est terminée"

Set boite = Nothing

End Sub

Vous aimerez peut-être aussi