je suis en train d’effecteur une petite exemple permettant d’afficher une data Grid selon plusieurs critère de recherche mais le pb que je pas réussi d'envoyer c'est résultat dans un fichier Excel
Private Sub Afficher_Click()
On Error Resume Next
oExcel.Quit
If (Combo1.ListIndex = 0) Then
DataEnvironment1.rstable.Filter = adFilterNone 'Enlever le filtre
DataGrid1.DataMember = "table"
DataGrid1.Refresh
ElseIf (Combo1.ListIndex = 1) Then
txt = DC1.BoundText
Private Sub Command1_Click()
' Dim sNWind As String
' Dim conn As New ADODB.Connection
' Dim rs As ADODB.Recordset
'sNWind = _
' "C:\Users\mourad\Documents\Monbase.mdb"
'conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
' sNWind & ";"
'conn.CursorLocation = adUseClient
'Set rs = conn.Execute("test", , adCmdTable)
Dim Rs As DAO.Recordset
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)
strExcelFile = "C:\Users\mourad\Documents\copie1.xlsx"
'Transfer the data to Excel
oSheet.Range("E1").Value = "Test Voyage"
oBook.Worksheets(1).Range("E1").Font.Name = "Verdana"
oBook.Worksheets(1).Range("E1").Font.Size = 15
oBook.Worksheets(1).Range("E1").Font.Color = RGB(178, 34, 34)
oSheet.Range("E1").Font.Bold = True
oSheet.Range("E2").Value = "Liste des Passagers"
oBook.Worksheets(1).Range("E2").Font.Size = 15
oSheet.Range("G2").Value = "Tél:0147823777"
oSheet.Range("G3").Value = "Fax:0147823778"
oSheet.Range("B4").Value = Date
Dim strResultat, i As String
strResultat = DataEnvironment1.rstable.RecordCount & " " & "PAX"
oSheet.Range("C6").Value = strResultat
oSheet.Range("B6").Value = "nombre des passagers"
oSheet.Range("C6:B6").Font.Size = 12
oSheet.Range("C6:G1").Font.Bold = True
oSheet.Range("A9:J9").Font.Color = RGB(178, 34, 34)
oSheet.Range("A9:J11").Font.Size = 13
oSheet.Range("A9:J11").Font.Bold = True
oSheet.Range("A9:J11").ColumnWidth = 23
i = "J"
i = i & (DataEnvironment1.rstable.RecordCount + 9)
oSheet.Range("A9", i).Value = Array("Réf", "Nom", "prénom", "Nom Pére", " Nom Grand Pére", "Sexe", "Date de Naissance", "Nationnalité", "pass N", "Date d'éxp")
oSheet.Range("A10").CopyFromRecordset DataEnvironment1.rstable