A voir également:
- Aperçu feuil de calcul excel depuis access
- Calcul moyenne excel - Guide
- Liste déroulante excel - Guide
- Si et excel - Guide
- Word et excel gratuit - Guide
- Aller à la ligne excel - Guide
1 réponse
salut, voici le code que j'ai usé.
Private Sub Commande15_Click()
Dim xl_app As New Excel.Application
Dim objexcel As Object
Dim XL_Feuille As Object
Dim dbs As Database, rst As DAO.Recordset
Dim a As Integer, b As Integer
With xl_app
Set objexcel = Workbooks.Open("C:\atelier\link.xls")
Set XL_Feuille = objexcel.Sheets("feuil1")
End With
b = Me.Modifiable13.Value
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("admis")
Do While Not rst.EOF
If rst![cclp] = b Then
If rst![trage] = 1 Then
If rst![SEXE] = "HOMME" Then
XL_Feuille.Range("d8").Value = rst![nbre]
Else
XL_Feuille.Range("e8").Value = rst![nbre]
End If
End If
If rst![trage] = 2 Then
…..
If rst![trage] = 7 Then
If rst![SEXE] = "HOMME" Then
XL_Feuille.Range("p8").Value = rst![nbre]
Else
XL_Feuille.Range("q8").Value = rst![nbre]
….
End If
rst.MoveNext
Loop
With xl_app
ActiveWorkbook.Worksheets ("feuil1").Printpreview
ActiveWorkbook.Close False
End With
Set xl_app = Nothing
Set objexcel = Nothing
End Sub
Merci
Private Sub Commande15_Click()
Dim xl_app As New Excel.Application
Dim objexcel As Object
Dim XL_Feuille As Object
Dim dbs As Database, rst As DAO.Recordset
Dim a As Integer, b As Integer
With xl_app
Set objexcel = Workbooks.Open("C:\atelier\link.xls")
Set XL_Feuille = objexcel.Sheets("feuil1")
End With
b = Me.Modifiable13.Value
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("admis")
Do While Not rst.EOF
If rst![cclp] = b Then
If rst![trage] = 1 Then
If rst![SEXE] = "HOMME" Then
XL_Feuille.Range("d8").Value = rst![nbre]
Else
XL_Feuille.Range("e8").Value = rst![nbre]
End If
End If
If rst![trage] = 2 Then
…..
If rst![trage] = 7 Then
If rst![SEXE] = "HOMME" Then
XL_Feuille.Range("p8").Value = rst![nbre]
Else
XL_Feuille.Range("q8").Value = rst![nbre]
….
End If
rst.MoveNext
Loop
With xl_app
ActiveWorkbook.Worksheets ("feuil1").Printpreview
ActiveWorkbook.Close False
End With
Set xl_app = Nothing
Set objexcel = Nothing
End Sub
Merci