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 27 28 29 30 31 32
| Private Sub RemplirDico(ByVal FichSce As String)
Dim sSQL As String, Client As String
Dim Cn As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Dim i As Integer
'--- Connection ---
With Cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & FichSce & ";Extended Properties=""Excel 12.0;HDR=YES;"""
.Open
End With
'--- Définit la requête ---
sSQL = "SELECT * FROM [Feuil1$]" '/!\ Attention à ne pas oublier le symbole $ après le nom de la feuille.
Set Rst = Cn.Execute(sSQL)
If Not Rst.EOF Then
Rst.MoveFirst
Do While Not Rst.EOF
Client = Rst(0).Value
If Len(Client) > 0 Then
Db = Db + 1
If Not Dico.Exists(UCase(Client)) Then Dico.Add UCase(Client), Client
End If
Rst.MoveNext
Loop
End If
Rst.Close
Set Rst = Nothing
Cn.Close
Set Cn = Nothing
End Sub |
Partager