Public Sub GetValueWithADO(fPath As String, fName As String, sName, cellRange As String)
Dim myConn As ADODB.Connection, myCmd As ADODB.Command, myRS As ADODB.Recordset
Dim VPathFic As String
' Construction du chemin d'accès
VPathFic = fPath & "\" & fName
[B][COLOR=green]' Penser à c[/COLOR][COLOR=green]ocher la référence : Microsoft ActiveX Data Object 2.6 Library[/COLOR][/B]
[B][COLOR=green] ' Ou supérieure[/COLOR][/B]
' Ouverture de la connexion et du recordset
Set myConn = New ADODB.Connection
myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & VPathFic & ";" & _
"Extended Properties=""Excel 8.0;HDR=No;IMEX=1;"""
Set myCmd = New ADODB.Command
myCmd.ActiveConnection = myConn
myCmd.CommandText = "SELECT * from [" & sName & "$" & cellRange & "]"
Set myRS = New ADODB.Recordset
myRS.Open myCmd, , adOpenKeyset, adLockOptimistic
' Restituer les données
ActiveSheet.Range(cellRange).CopyFromRecordset myRS
' Fermer la connection
myConn.Close
Set myRS = Nothing
Set myCmd = Nothing
Set myConn = Nothing
End Sub