Bonjour,

Je cherche à exporter une requête access sous forme de fichier csv.
Le code suivant permet de faire l'export au format excel mais comment l'adapter pour export au format CSV ?

Le code suivant est appelé par appui sur un bouton :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Private Sub cmd_refsi_calipso_Click()
On Error GoTo Err_Click
 
    Dim sRequete As String
    Dim sDate As String
    Dim sFichierXls As String
    Dim i, j As Integer
 
    OracleConnect
 
    'Me.Commande0_ListeClients.Enabled = False
    Me.Status = "Génération en cours, patientez S.V.P."
 
    sRequete = "emetteurs_calipso"
    DoCmd.SetWarnings False
    DoCmd.OpenQuery sRequete
 
    DoEvents
 
    'Creation du nom de fichier
    sDate = Format(CStr(Date), "yyyymmdd") & "_" & Replace(CStr(Time), ":", "")
    sFichierXls = "c:\temp\rcc_" & sRequete & "_" & sDate & " .xls"
    If Dir(sFichierXls) <> "" Then
        Kill sFichierXls
    End If
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, sRequete, sFichierXls, True
    DoCmd.Close
 
    Dim ExcelApplication As Object
    Set ExcelApplication = CreateObject("Excel.Application")
    ExcelApplication.Application.Visible = True
    ExcelApplication.Workbooks.Open Filename:=sFichierXls
 
    ExcelApplication.ActiveWorkbook.Save
    ExcelApplication.ActiveWorkbook.Close False
    ExcelApplication.Application.Quit
    Set ExcelApplication = Nothing
 
    DoEvents
 
    Me.Status = "Génération effectuée avec succès!"
 
Err_Click:
    MsgBox Err.Description
    Resume Exit_Click
Exit_Click:
    Exit Sub
End Sub
Merci pour votre retour.