A voir également:
- Interaction VB6 - Access 2000 - Excel 2000
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Si et excel - Guide
- Déplacer une colonne excel - Guide
- Comment calculer la moyenne sur excel - Guide
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
----------------------------------------------------------------------------
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
----------------------------------------------------------------------------
2 mai 2002 à 09:53
Un grand merci pour ta solution!
C'est évident, pourquoi n'y avais-je pas pensé?
Bien à toi,
Jacques LAMOTTE
2 mai 2002 à 21:27