jpleroisse
Messages postés1788Date d'inscriptionmardi 7 novembre 2000StatutMembreDernière intervention11 mars 200627 21 nov. 2005 à 15:09
Bonjour,
Dans Projet/Références, tu coches Microsoft Excel x.0
Object Library Ensuite tu places ce code(Si tu as donnés des noms à tes
contrôles ADODC et DataGrid, change le code en fonction de celà).
Private Sub Command1_Click()
Dim i, j
Dim Ex As New Excel.Application 'Declaration
Set Ex = New Excel.Application 'Initialisation de l'objet
Ex.Workbooks.Add 'nouveau classeur,Ex.Workbooks.Add "Nom du fichier excel"'Ouverture d'un fichier excel existant
Adodc1.Refresh
Ex.Cells(2, 1) = "Société"
Ex.Cells(2, 2) = "Commande"
Ex.Cells(2, 3) = "Date Livraison"
Ex.Cells(2, 4) = "Montant TTC"
j = 3
While Not Adodc1.Recordset.EOF
For i = 0 To 3
Ex.Cells(j, i + 1) = DataGrid1.Columns(i)
Next
Adodc1.Recordset.MoveNext
j = j + 1
Wend
Ex.Visible = True
End Sub
jpleroisse
Si une réponse vous convient, cliquez Réponse Acceptée.