OVH Cloud OVH Cloud

Access et Excel

1 réponse
Avatar
Bonjour
J'ai des données dans une base de donneées Access est t-il possible de les
traiter avec Excel?

1 réponse

Avatar
Philippe
Salut

Voici un peu de code qui pourra t'aider (j'espère...)

Sub ACCESS_EXCEL(
' pour faire appel aux objets "Database" et "Recordset", il faut sélectionne
' "Microsoft DAO 3.5 Object Library" dans le menu Outils/Référence

Dim db As Databas
Dim rst As Recordse
Dim t As Lon
Dim Chrono As Singl

Application.ScreenUpdating = Fals
Chrono = Time

Set db = OpenDatabase("D:Mes DocumentsBase Test.mdb"
Set rst = db.OpenRecordset("SELECT * FROM Source;"

Cells.Clea
Range("A2").CopyFromRecordset rs
For t = 0 To rst.Fields.Count -
Cells(1, t + 1).Value = rst.Fields(t).Nam
Nex

Range(Cells(1, 1), Cells(1, t)).Selec
With Selectio
.Font.Bold = Tru
.EntireColumn.AutoFi
.HorizontalAlignment = xlCente
.VerticalAlignment = xlCente
End Wit

Range("A1").CurrentRegion.BorderAround
LineStyle:=xlContinuous, Weight:=xlThick, ColorIndex:=xlColorIndexAutomati

Range("A1").Selec

Application.ScreenUpdating = Tru
Debug.Print "Temps" & vbTab & Timer - Chron
Bee
Set db = Nothing: Set rst = Nothin
End Su