Salut
Moi sur Excel 2003 ca ne pose pas de probleme
J'ai modifié ainsi pour tester et Val contient bien le nom du fichier, attention par contre le \ au debut du nom de fichier est concervé.
Attention aussi a declartion de variable
n'est pas equivalent a
Dim a as string, b as sting
mais a
dim a as variant, b as string
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
| Sub liste_of()
'Les declaration doivent se faire ainsi sinon celles qui non pas de As .. a la suite seront conciderées comme des variants
Dim val As String, rep As String
Dim deb As Long, tot As Long, dif As Long
'UserForm1.ComboBox2.Clear
rep = "D:\éssai" '"G:\DP\pf_mcore\CR_Intégration\" & UserForm1.ComboBox1.Value & "\En cours de test\"
deb = Len(rep)
With Application.FileSearch
.LookIn = rep
.Filename = "*.*"
If .Execute = 0 Then
Exit Sub
Else
'UserForm1.ComboBox2.Clear
For i = 1 To .FoundFiles.Count
tot = Len(.FoundFiles(i))
dif = tot - deb
val = Right(.FoundFiles(i), dif) 'attention ici tu concerve le \ avant le nom de ton fichier
tot = Len(val)
dif = tot - 4
val = Left(val, dif)
'UserForm1.ComboBox2.AddItem (UCase(val))
Next i
End If
End With
End Sub |
++
Qwaz
Partager