Bonjour,
Je me permets de déterrer un vieux sujet car il correspond exactement à ma demande et je ne veux pas créer de doublon
J'ai utilisé le code fourni par Banzai64 mais le userform ne se ferme jamais
Je pense avoir mal placé le "Unload USFWait"...
Pouvez vous m'aider ?
Un grand merci par avance,
Bonne journée,
Loïc
Function LireCellule_ClasseurFerme( _
Chemin As String, _
Fichier As String, _
Feuille As String, _
Cellule As Variant) As Variant
USFWait.Show 0
USFWait.Repaint
Application.Volatile
Dim Source As Object, Rst As Object, ADOCommand As Object
Dim Cible As String
Feuille = Feuille & "$"
Cible = Cellule.Address(0, 0, xlA1, 0) & ":" & _
Cellule.Address(0, 0, xlA1, 0)
Set Source = CreateObject("ADODB.Connection")
Source.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Chemin & "\" & Fichier & _
";Extended Properties=""Excel 8.0;HDR=No;"";"
Set ADOCommand = CreateObject("ADODB.Command")
With ADOCommand
.ActiveConnection = Source
.CommandText = "SELECT * FROM [" & Feuille & Cible & "]"
End With
Set Rst = CreateObject("ADODB.Recordset")
'1 = adOpenKeyset, 3 = adLockOptimistic
Rst.Open ADOCommand, , 1, 3
Set Rst = Source.Execute("[" & Feuille & Cible & "]")
LireCellule_ClasseurFerme = Rst(0).Value
Rst.Close
Source.Close
Set Source = Nothing
Set Rst = Nothing
Set ADOCommand = Nothing
Unload USFWait
End Function