![]() |
|
Forum
|
|
|
#1 (permalink) |
|
XLDnaute Occasionel
Date d'inscription: juillet 2006
Messages: 103
|
Bonjour
J'ai recupere ce code que j'aimerais adapte Il recherche la date de creation, de modification des fichiers Il faut place en a1 le nom du fichiers sous la forme C:\tmp\test.xls "on peut recherche plusieurs fichiers" puis la macro va cherche les infos Le probleme , j'aimerais que les infos ainsi trouvées soit place dans une listbox "Je n'arrive pas a la crée (le resultat varie en fonction du nombre de fichiers a recherche)". Code:
Sub test()
Dim fin As Long 'déclare la variable fin
Dim b As Long 'déclare la variable b
'Dim b, fs, f, s 'déclare la variable fs,f,s
fin = Range("a65536").End(xlUp).Row 'définit la variable de fin
For b = 1 To fin 'boucle
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(Range("a" & b))
'affiche le resultat
Range("a" & (b + 4)) = Range("a" & b)
Range("a" & (b + 5)) = "Créé le : " & f.DateCreated
Range("a" & (b + 6)) = "Dernier accès le : " & f.DateLastAccessed
Range("a" & (b + 7)) = "Dernière modification le : " & f.DateLastModified
Next b
End Sub
Merci de votre aide |
|
|
|
| ANNONCES | |||
|
|
|
|
#2 (permalink) |
|
XLDnaute Occasionel
Date d'inscription: mai 2005
Messages: 129
|
Salut,
As-tu essayé ceci : Sub test() Dim fin As Long 'déclare la variable fin Dim b As Long 'déclare la variable b 'Dim b, fs, f, s 'déclare la variable fs,f,s fin = Range("a65536").End(xlUp).Row 'définit la variable de fin Feuil1.ListBox1.Clear For b = 1 To fin 'boucle Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFile(Range("a" & b)) 'affiche le resultat Feuil1.ListBox1.AddItem Range("a" & b) Feuil1.ListBox1.AddItem "Créé le : " & f.DateCreated Feuil1.ListBox1.AddItem "Dernier accès le : " & f.DateLastAccessed Feuil1.ListBox1.AddItem "Dernière modification le : " & f.DateLastModified Next b End Sub Mais tu dois placer une listbox sur ta feuille excel !!!! sinon tu aura un message d'erreur. Bonne fin de journée. John |
|
|
|
|
|
#3 (permalink) |
|
XLDnaute Occasionel
Date d'inscription: juillet 2006
Messages: 103
|
Merci pour la reponse
voici le code Code:
Sub Info_fichiers()
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
s = UCase(" Date creation") & vbTab & vbTab
s = s & "Date dernier acces" & vbTab & vbTab
s = s & "Date dernier modification" & vbTab
s = s & "Nom fichiers" & vbCrLf
s = s & " ---------------------" & vbTab & vbTab
s = s & " -----------------------" & vbTab & vbTab
s = s & " -----------------------------" & vbTab
s = s & " ------------------" & vbCrLf & vbCrLf
fin = Range("B65536").End(xlUp).Row 'définit la variable fin
For b = 1 To fin 'boucle
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(Range("B" & b))
s = s & f.DateCreated & vbTab
s = s & f.DateLastAccessed & vbTab
s = s & f.DateLastModified & vbTab
s = s & Range("B" & b) & vbTab & vbCrLf
Next b
MsgBox s, 0, "Infos d'accès au fichier"
End Sub
|
|
|
|
| ANNONCES | |
![]() |
| Liens sociaux |
| Outils de la discussion | |
|
|
Discussions similaires
|
||||
| Discussion | Auteur | Forum | Réponses | Dernier message |
| progress bar , creation d'une boucle ? | avoriaz | Forum Excel | 8 | 25/03/2006 14h18 |
| création d'une fonction vba | julien | Forum Excel | 1 | 03/12/2005 04h23 |
| Création d'une fonction | Lionel | Forum Excel Downloads - Archives | 2 | 20/11/2004 14h33 |
| Création d'une fonction | Carl | Forum Excel Downloads - Archives | 5 | 18/11/2004 16h14 |
| creation d'une fonction | jane | Forum Excel Downloads - Archives | 4 | 22/07/2003 12h31 |