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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
| 'Vérifier si des données sont à exporter
Dim oRst As DAO.Recordset
Dim oDb As DAO.Database
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT * FROM [Base de données] WHERE (Donnees_exporter)=Yes", dbOpenDynaset)
If oRst.EOF Then
MsgBox "Aucune donnée n'est actuellement destinée à être exportée." & Chr(10) & "Veuillez sélectionner des données et recommencer l'opération.", vbOKOnly + vbExclamation, "ECHEC A L'EXPORTATION"
' Ouvrir le formulaire "Accueil"
DoCmd.OpenForm "Accueil", acNormal, "", "", , acNormal
Exit Sub
Else
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
'Vider le contenu du répertoire "Envoi" dans la corbeille
Call DansCorbeille("c:\cmi\envoi\*.*", Me.hwnd)
'Variables
Dim Adresse1, Adresse2, Adresse3, Adresse4, Adresse5, Adresse6 As String
Dim Fichier1, Fichier2, Fichier3, Fichier4, Fichier5, Fichier6 As String
Dim sEmplacementInitial As String, sEmplacementFinal As String
Dim sEmplacementInitial1 As String, sEmplacementFinal1 As String
Dim sEmplacementInitial2 As String, sEmplacementFinal2 As String
Dim sEmplacementInitial3 As String, sEmplacementFinal3 As String
Dim sEmplacementInitial4 As String, sEmplacementFinal4 As String
Dim sEmplacementInitial5 As String, sEmplacementFinal5 As String
Dim sEmplacementInitial6 As String, sEmplacementFinal6 As String
'Récupération adresse photo1
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT Photo1 FROM [Base de données] WHERE ((Donnees_exporter) = True AND (Photo1) <> '')", dbOpenDynaset)
While Not oRst.EOF
Adresse1 = oRst.Fields("Photo1").Value
'Sélection du fichier dans Adresse1
Fichier1 = Mid(Adresse1, 15)
'Copie du fichier photo1 dans le répertoire c:\cmi\envoi
sEmplacementInitial1 = Adresse1
'Emplacement final est c:\cmi\envoi\"nom de la photo"
'Concaténation du tronc commun c:\cmi\envoi et du nom de la photo (=Fichier1)
sEmplacementFinal1 = "c:\cmi\envoi\" & Fichier1
FileCopy sEmplacementInitial1, sEmplacementFinal1
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
'Récupération adresse photo2
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT Photo2 FROM [Base de données] WHERE ((Donnees_exporter) = True AND (Photo2) <> '')", dbOpenDynaset)
While Not oRst.EOF
Adresse2 = oRst.Fields("Photo2").Value
'Sélection du fichier dans Adresse2
Fichier2 = Mid(Adresse2, 15)
'Copie du fichier photo2 dans le répertoire c:\cmi\envoi
sEmplacementInitial2 = Adresse2
'Emplacement final est c:\cmi\envoi\"nom de la photo"
'Concaténation du tronc commun c:\cmi\envoi et du nom de la photo (=Fichier2)
sEmplacementFinal2 = "c:\cmi\envoi\" & Fichier2
FileCopy sEmplacementInitial2, sEmplacementFinal2
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
'Récupération adresse photo3
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT Photo3 FROM [Base de données] WHERE ((Donnees_exporter) = True AND (Photo3) <> '')", dbOpenDynaset)
While Not oRst.EOF
Adresse3 = oRst.Fields("Photo3").Value
'Sélection du fichier dans Adresse3
Fichier3 = Mid(Adresse3, 15)
'Copie du fichier photo3 dans le répertoire c:\cmi\envoi
sEmplacementInitial3 = Adresse3
'Emplacement final est c:\cmi\envoi\"nom de la photo"
'Concaténation du tronc commun c:\cmi\envoi et du nom de la photo (=Fichier3)
sEmplacementFinal3 = "c:\cmi\envoi\" & Fichier3
FileCopy sEmplacementInitial3, sEmplacementFinal3
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
'Récupération adresse photo4
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT Photo4 FROM [Base de données] WHERE ((Donnees_exporter) = True AND (Photo4) <> '')", dbOpenDynaset)
While Not oRst.EOF
Adresse4 = oRst.Fields("Photo4").Value
'Sélection du fichier dans Adresse4
Fichier4 = Mid(Adresse4, 15)
'Copie du fichier photo4 dans le répertoire c:\cmi\envoi
sEmplacementInitial4 = Adresse4
'Emplacement final est c:\cmi\envoi\"nom de la photo"
'Concaténation du tronc commun c:\cmi\envoi et du nom de la photo (=Fichier4)
sEmplacementFinal4 = "c:\cmi\envoi\" & Fichier4
FileCopy sEmplacementInitial4, sEmplacementFinal4
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
'Récupération adresse photo5
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT Photo5 FROM [Base de données] WHERE ((Donnees_exporter) = True AND (Photo5) <> '')", dbOpenDynaset)
While Not oRst.EOF
Adresse5 = oRst.Fields("Photo5").Value
'Sélection du fichier dans Adresse5
Fichier5 = Mid(Adresse5, 15)
'Copie du fichier photo5 dans le répertoire c:\cmi\envoi
sEmplacementInitial5 = Adresse5
'Emplacement final est c:\cmi\envoi\"nom de la photo"
'Concaténation du tronc commun c:\cmi\envoi et du nom de la photo (=Fichier5)
sEmplacementFinal5 = "c:\cmi\envoi\" & Fichier5
FileCopy sEmplacementInitial5, sEmplacementFinal5
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
'Récupération adresse photo6
Set oDb = CurrentDb
Set oRst = oDb.OpenRecordset("SELECT Photo6 FROM [Base de données] WHERE ((Donnees_exporter) = True AND (Photo6) <> '')", dbOpenDynaset)
While Not oRst.EOF
Adresse6 = oRst.Fields("Photo6").Value
'Sélection du fichier dans Adresse1
Fichier6 = Mid(Adresse6, 15)
'Copie du fichier photo6 dans le répertoire c:\cmi\envoi
sEmplacementInitial6 = Adresse6
'Emplacement final est c:\cmi\envoi\"nom de la photo"
'Concaténation du tronc commun c:\cmi\envoi et du nom de la photo (=Fichier6)
sEmplacementFinal6 = "c:\cmi\envoi\" & Fichier6
FileCopy sEmplacementInitial6, sEmplacementFinal6
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing
DoEvents
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM Importation", -1
DoCmd.OpenQuery "ExportationDonnees", acViewNormal, acEdit
DoCmd.OpenQuery "Ajout_print_donnees", acViewNormal, acEdit
DoCmd.OpenQuery "Ajout_visualisation", acViewNormal, acEdit
DoCmd.OpenQuery "Suppress_diffusion_donnees", acViewNormal, acEdit
Beep
CreateObject("Wscript.shell").PopUp "Données exportées avec succès", 1, "Information", vbInformation
DoCmd.SetWarnings True
'Copie du fichier 'Echange_donnees' dans répertoire c:\cmi\envoi
sEmplacementInitial = "c:\cmi\Echange_donnees.mdb"
sEmplacementFinal = "c:\cmi\envoi\Echange_donnees.mdb"
FileCopy sEmplacementInitial, sEmplacementFinal
'Changer extension du fichier Echange_donnees de .mdb en .txt"
Name "c:\cmi\envoi\Echange_donnees.mdb" As "c:\cmi\envoi\Echange_donnees.txt"
End If |
Partager