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
| Function Export_CSV()
'Chemin du fichier ouvert
Chemin = ThisWorkbook.Path
'Nom du fichier
nomFic = "Q_export.csv"
'Création du fichier
Open Chemin & "\" & nomFic For Append As #1
'Ajout des lignes
SQL = "SELECT T_Stock.Motorisation, T_Stock.Description, "Home, " & [T_Véhicule]![Marque] & ", " & [T_Véhicule]![Modèle] AS Catégories, T_Stock.TTC_AlterAuto, [T_Véhicule]![Marque] AS SUPPLIER, [T_Véhicule]![Marque] AS Manufacturer, T_Stock.Options, T_Véhicule.[Meta-title], T_Véhicule.[Meta-keywords], T_Véhicule.[Meta-description], T_Véhicule.[URL rewritten], [T_Véhicule]![Image1] & ", " & [T_Véhicule]![Image2] & ", " & [T_Véhicule]![Image3] & ", " & [T_Véhicule]![Image4] & ", " & [T_Véhicule]![Image5] AS [Image], IIf([T_Stock]![Dispo]=True,"1","0") AS Dispo, T_Stock.[Code AlterAuto], T_Stock.Date_Ajout
FROM T_Stock INNER JOIN T_Véhicule ON T_Stock.Modèle = T_Véhicule.Modèle;"
Set oSQL = CurrentDb.OpenRecordset(SQL)
With oSQL
Do While Not .EOF
Print #1, oSQL![CHAMP1] & ";" & oSQL![CHAMP2] & ....
oSQL.MoveNext
Loop
End With
oSQL.Close
'Permet de fermer le fichier
Close #1
End Function |
Partager