Dim MonRepertoire, fa, fe, x As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
chem = "C:\mondossier"
MonRepertoire = chem & importcombo.siglecombobox.Text
x = 1
For Each fa In fso.GetFolder(MonRepertoire).Files
lsigle = Len(importcombo.siglecombobox.Text)
ldevise = Len(importcombo.devisecombobox.Text)
fe = fa.Name
fe = Mid(fe, lsigle + ldevise + 5, 6)
importcombo.date1combobox.AddItem fe
x = x + 1
Next fa
importcombo.devisecombobox.Clear
Dim MonRepertoire, fa, fe, x As Integer, Dico, Tablo
Set fso = CreateObject("Scripting.FileSystemObject")
Set Dico = CreateObject("Scripting.Dictionary")
chem = Sheets("system").Range("A25").Value
MonRepertoire = chem & importcombo.siglecombobox.Text
x = 1
For Each fa In fso.GetFolder(MonRepertoire).Files
lsigle = Len(importcombo.siglecombobox.Text)
fe = fa.Name
fe = Mid(fe, lsigle + 2, 3)
Dico(fe) = fe
x = x + 1
Next fa
Tablo = Dico.keys
Set Dico = Nothing
Set fso = Nothing
For x = LBound(Tablo) To UBound(Tablo)
importcombo.devisecombobox.AddItem Tablo(x)
Next x
Sub tri(a() As Double, 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
Sub MaMacro()
importcombo.devisecombobox.Clear
Dim MonRepertoire, fa, fe, x As Integer, Dico, Tablo, Dte as Date
Set fso = CreateObject("Scripting.FileSystemObject")
Set Dico = CreateObject("Scripting.Dictionary")
chem = Sheets("system").Range("A25").Value
MonRepertoire = chem & importcombo.siglecombobox.Text
x = 1
For Each fa In fso.GetFolder(MonRepertoire).Files
lsigle = Len(importcombo.siglecombobox.Text)
fe = fa.Name
fe = Mid(fe, lsigle + 2, 3)
Dte = Dateserial(2000 + cint(right(fe,2)), cint(mid(fe,3,2)), cint(left(fe,2)))
Dico(CLng(Dte)) = Clng(Dte)
x = x + 1
Next fa
Tablo = Dico.keys
Tri(Tablo, lbound(tablo), ubound(tablo))
Set Dico = Nothing
Set fso = Nothing
For x = LBound(Tablo) To UBound(Tablo)
importcombo.devisecombobox.AddItem format(Tablo(x),"DDMMYY")
Next x
End sub
Tri Tablo, LBound(Tablo), Ubound(Tablo)
Sub tri(a, gauc, droi) ' Quick sort
Dim MonRepertoire, fa, fe, x As Integer, Dico, Tablo
Set fso = CreateObject("Scripting.FileSystemObject")
Set Dico = CreateObject("Scripting.Dictionary")
chem = Sheets("system").Range("A25").Value
MonRepertoire = chem & importcombo.siglecombobox.Text
x = 1
For Each fa In fso.GetFolder(MonRepertoire).Files
lsigle = Len(importcombo.siglecombobox.Text)
ldevise = Len(importcombo.devisecombobox.Text)
fe = fa.Name
fe = Mid(fe, lsigle + ldevise + 5, 6)
Dico(fe) = fe
x = x + 1
Next fa
Tablo = Dico.keys
Set Dico = Nothing
Set fso = Nothing
For x = LBound(Tablo) To UBound(Tablo)
importcombo.date1combobox.AddItem Tablo(x)
Next x
Il me sort erreur d'execution 13 : Incompatibilitée de type à la ligne Dte = date..
importcombo.date1combobox.Clear
Dim MonRepertoire, fa, fe, x As Integer, Dico, Tablo, Dte As Date
Set fso = CreateObject("Scripting.FileSystemObject")
Set Dico = CreateObject("Scripting.Dictionary")
chem = Sheets("system").Range("A25").Value
MonRepertoire = chem & importcombo.siglecombobox.Text
x = 1
For Each fa In fso.GetFolder(MonRepertoire).Files
lsigle = Len(importcombo.siglecombobox.Text)
ldevise = Len(importcombo.devisecombobox.Text)
fe = fa.Name
fe = Mid(fe, lsigle + ldevise + 5, 6)
Dte = DateSerial(2000 + CInt(Right(fe, 2)), CInt(Mid(fe, 3, 2)), CInt(Left(fe, 2)))
Dico(CLng(Dte)) = CLng(Dte)
x = x + 1
Next fa
Tablo = Dico.keys
tri Tablo, LBound(Tablo), UBound(Tablo)
Set Dico = Nothing
Set fso = Nothing
For x = LBound(Tablo) To UBound(Tablo)
importcombo.date1combobox.AddItem Format(Tablo(x), "DDMMYY")
Next x
Sub tri(a, gauc, droi) ' Quick sort décroissant
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