1 pièce(s) jointe(s)
"l'indice n'appartient pas à la sélection"
Bonjour ,
Issu de M.Boisgontier je cherche en vain à faire fonctionner ce bout de programme :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Private Sub UserForm_Initialize()
rep = ThisWorkbook.Path & "\Phots" ' adapter
Set mondico = CreateObject("Scripting.Dictionary")
Set myShell = CreateObject("Shell.Application")
Set myFolder = myShell.Namespace(rep)
nf = Dir(rep & "*.jpg")
Do While nf <> ""
Set myFile = myFolder.items.Item(nf)
cmt = myFolder.GetDetailsOf(myFile, 14)
If cmt <> "" Then
b = Split(cmt, ",")
For Each k In b
tmp = LCase(k)
mondico.Item(tmp) = tmp
Next k
End If
nf = Dir
Loop
temp = mondico.items
Call tri(temp, LBound(temp), UBound(temp))
Me.ComboBox1.List = temp
End Sub |
===
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Sub tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, g, droi)
If gauc < d Then Call tri(a, gauc, d)
End Sub |
La problématique apparait au moment du tri à la ligne 'ref = a((gauc + droi) \ 2)' .
Le message d'erreur est "erreur exécution 9 , l'indice n'appartient pas à la sélection"
J'ai pensé à regarder si 'Microsoft Scripting Runtime' était bien activé , mais je ne dois pas partir sur des bases correctes ...
Pouvez-vous me guider svp ...
Merci.
Bien cordialement.
Max60fr.
ci-joint fichier: