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
|
Dim i, j, k, l As Integer
On Error GoTo errxcel
Dim xlo As Object
Set xlo = CreateObject("Excel.Application")
DoEvents
xlo.Visible = True
xlo.workbooks.Add
i = rsProv1.RecordCount
j = DataGrid1.Columns.Count
For k = 0 To j - 1
xlo.workbooks(1).sheets(1).Cells(l + 1, k + 1) = DataGrid1.Columns(k).Caption
Next k
l = 0
rsProv1.MoveFirst
Do While Not rsProv1.EOF
For k = 0 To j - 1
DataGrid1.Col = k
xlo.workbooks(1).sheets(1).Cells(l + 2, k + 1) = DataGrid1.Text
Next k
rsProv1.MoveNext
l = l + 1
Loop
Exit Sub
errxcel:
MsgBox "Excel not found" |
Partager