Interaction VB6 - Access 2000 - Excel 2000

Fermé
Jacques Lamotte - 30 avril 2002 à 15:20
 MarsuGL - 2 mai 2002 à 21:27
A partir d'une application VB6, comment exporter des données sélectionnées par une requête SQL dans une base Access 2000 dans une feuille Excell 2000 afin des les traiter. (statistiques et graphiques).
A voir également:

1 réponse

Salut,
pourquoi a partir d´une application VB, tu peut aussi exporter tes donnée directement de la base de donnée sous form d´exell.
si c nacessair du VB ben voici un exemple de code :
----------------------------------------------------------------------------Private Function LocalPlan_Excel()
'-- Send records to excel --'

'Records Set
Dim rs As Recordset
'Max Column
Dim intMax_c As Integer
'Max Row
Dim intMax_r As Integer
'application
Dim objXL As Excel.Application
'work book
Dim objwb As Workbook
'work sheet
Dim objsheet As Worksheet

'Set the database
Set rs = CurrentDb.Recordset("LocalPlan", dbOpenSnapshot)
'set the max column
intMax_c = rs.Fields.Count

If rs.RecordCount > 0 Then

rs.MoveLast: rs.MoveFirst
'set the max Record Count
intMax_r = rs.RecordCount

Set objXL = New Excel.Application
With objXL.Visible = True
Set objwb = .Workbooks.Add
Set objsheet = objwb.Worksheet(1)
With objsheet
.Ranage(.Cells(1, 1), .Cells(intMax_r, intMax_c)).CopyFromRecordset rs
End With
End With

End If


End Function

----------------------------------------------------------------------------
0
Jacques Lamotte
2 mai 2002 à 09:53
Salut,
Un grand merci pour ta solution!
C'est évident, pourquoi n'y avais-je pas pensé?
Bien à toi,
Jacques LAMOTTE
0
Certains appellent ausi excel a partir de vb par lien ole pour faire des etats.
0