Bonjour,

J'aimerais exporter les résultats d'une requête vers un fichier excel que ma macro génère. Problème je suis bloqué après la création du fichier.

Je n'arrive pas à trouver des tutos. Pouvez vous m'aider ou m'orienter svp ?

Voici ce que j'ai ecrit :

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
Private Sub Commande3_Click()
 
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
 
 'CREATION D UN FICHIER EXCEL
    Set xlApp = CreateObject("Excel.Application")
 'NOMBRE D'ONGLET
    xlApp.SheetsInNewWorkbook = 2
 'AJOUT D'UN CLASSEUR
    Set xlBook = xlApp.Workbooks.Add
 'NOM DU CLASSEUR
    xlBook.SaveAs ("Synthèse projet PPNE RMN.xls")
  'CLASSEUR VISIBLE
    xlApp.Visible = True
 'CREATION OBJET ONGLET
    Set xlSheet = xlBook.Worksheets(1)
  'NOM DE L ONGLET    xlSheet.Name = "Synthèse projet"
 'LIBERATION DE L'ONGLET POUR EN CREER UN NOUVEAU
    Set xlSheet = Nothing
    Set xlSheet = xlBook.Worksheets(2)
    xlSheet.Name = "Teste"
 'PROPRIETE A 2
    xlApp.SheetsInNewWorkbook = 2
Cordialement Mykimix