- Dim sheet As Object
- Dim exldoc As Object
- Dim exlapp As Object
- Dim i As Integer
- Dim j As Integer
-
- Set exlapp = CreateObject("excel.application")
- Set exldoc = exlapp.workbooks.Open("p:\logement\doc\test.xls")
- Set sheet = exlapp.ActiveWorkbook.ActiveSheet
- i = 0
- For i = 0 To votre_rst.Fields.Count - 1
- sheet.Cells(1, i + 1).Value = votre_rst.Fields(i).Name
- Next i
-
- i = 0
- j = 2
-
- Do While votre_rst.EOF = False
-
- For i = 0 To votre_rst.Fields.Count - 1
-
- If IsDate(votre_rst.Fields(i)) Then
- sheet.Cells(j, i + 1).NumberFormat = "dd/mm/yyyy"
- End If
-
- If VarType(votre_rst.Fields(i)) = 5 Then
- sheet.Cells(j, i + 1).NumberFormat = "#########0.00"
- End If
-
- sheet.Cells(j, i + 1).Value = votre_rst.Fields(i)
-
- Next i
-
- j = j + 1
-
- votre_rst.MoveNext
- Loop
-
- exldoc.Close
- exlapp.quit
-
- Set exlapp = Nothing
- Set exldoc = Nothing
- End Function
Dim sheet As Object
Dim exldoc As Object
Dim exlapp As Object
Dim i As Integer
Dim j As Integer
Set exlapp = CreateObject("excel.application")
Set exldoc = exlapp.workbooks.Open("p:\logement\doc\test.xls")
Set sheet = exlapp.ActiveWorkbook.ActiveSheet
i = 0
For i = 0 To votre_rst.Fields.Count - 1
sheet.Cells(1, i + 1).Value = votre_rst.Fields(i).Name
Next i
i = 0
j = 2
Do While votre_rst.EOF = False
For i = 0 To votre_rst.Fields.Count - 1
If IsDate(votre_rst.Fields(i)) Then
sheet.Cells(j, i + 1).NumberFormat = "dd/mm/yyyy"
End If
If VarType(votre_rst.Fields(i)) = 5 Then
sheet.Cells(j, i + 1).NumberFormat = "#########0.00"
End If
sheet.Cells(j, i + 1).Value = votre_rst.Fields(i)
Next i
j = j + 1
votre_rst.MoveNext
Loop
exldoc.Close
exlapp.quit
Set exlapp = Nothing
Set exldoc = Nothing
End Function