Ils fonctionnent en VBA mais ils sont inconnus dans l'aide.
Où puis-je avoir plus de renseignements?
Cela m?aiderait à solutionner la 3ième partie de mon problème :
Ouvrir un fichier dont j'ai le path (word, excel, courriel, .pdf etc)
Le code suivant fonctionne très bien dans un module Access 2000!
Sub CréerRépertoire()
' conversion du 1er caractère du mois actuel en majuscule
Dim m1, m2, mm, path1, path2
Dim fso, f, f1, fichier, Subfichier, Resultat
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path1)
If Not fso.FolderExists(path2) Then
Set f = fso.CreateFolder(path2)
Else
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'lecture des répertoires contenus dans path1
Set f = fso.GetFolder(path1)
For Each Subfichier In f.SubFolders
MsgBox "vérification du nom du répertoire traité: " & Subfichier
'lecture des fichiers contenus dans les sous-répertoires de path1
Set f1 = Subfichier.Files
For Each fichier In f1
Resultat = Resultat & vbCrLf & vbCrLf & fichier
Next
Next
MsgBox Resultat
Set fso = Nothing
'Les 4 lignes suivantes ne fonctionnent pas avec ma version d'access 2000
' mais pas nécessaires pour la solution de mon problême
'Dim wshShell
'Set wshShell = wscript.CreateObject("WScript.Shell")
'Verif = wshShell.PopUp(Resultat & vbCrLf & vbCrLf, 20, "Le répertoire " & path1 & " contient les sous-répertoires et fichiers suivants: ")
'wscript.Quit
cs_jeanmarc
Messages postés34Date d'inscriptionmardi 18 juin 2002StatutMembreDernière intervention22 novembre 2005 27 oct. 2005 à 01:14
Bonsoir,
J'ai avancé pour "ton" script.
J'ai ajouté des tests évidents.
C'est écrit en VBS, mais on peux l'insérer dans du VBA.
'1) Ajouter, par exemple, le répertoire "ClientDuMoisOctobre" dans le répertoire "c:\ClientsDe2005"
'2)Plus tard afficher à l'écran les fichiers de "c:\ClientsDe2005\ClientDuMoisOctobre"
' Test si path "ClientDuMoismm" existe'
'
' conversion du 1er caractère du mois actuel en majuscule
Dim m1, m2, mm, path1, path2, dossier, fichiers, fso, f1, fso1, f2, fichier
m1 = DatePart("m", Date)
m2 = Array("","janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre")
mm = m2(m1)
mois = Ucase(Left(mm, 1)) & Mid(mm, 2)
'msgbox "mois windows: " & mm &vbCrLf&"mois modifié : " & mois
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path1)
If Not fso.FolderExists(path2) Then
Set f = fso.CreateFolder(path2)
' msgBox "Création du répertoire " & path2 & " effectuée" &vbCrLf&vbCrLf& "Copie des fichiers du répertoire " & path1 &vbCrLf& "vers " & path2 & " effectuée",vbInformation
Else
' msgBox "Copie des fichiers du répertoire " & path1 &vbCrLf& "vers " & path2 & " effectuée",vbInformation
End if
For Each fichier in f.Files
' msgbox fichier & " test2"
fso.CopyFile fichier, path2
msgBox "Copie du fichier " & f.Name & " du répertoire " & path1 &vbCrLf& "vers " & path2 & " effectuée",vbInformation
Next
Set fso = Nothing
Dim wshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\EXPLORER.EXE /n,/e," & path2
wscript.Quit
Vous n’avez pas trouvé la réponse que vous recherchez ?
cs_ordino
Messages postés20Date d'inscriptionmercredi 18 août 2004StatutMembreDernière intervention13 novembre 2012 27 oct. 2005 à 03:56
Merci beaucoup. J'ai beaucoup apris aujourd'hui.
J'ai encore à aprendre (voir **** dans mon code)
Voici ma version VBA:
Option Compare Database
Sub CréerRépertoire()
'1) Ajouter, par exemple, le répertoire "ClientDuMoisOctobre" dans le répertoire "c:\ClientsDe2005"
'2)Plus tard afficher à l'écran les fichiers de "c:\ClientsDe2005\ClientDuMoisOctobre"
' Test si path "ClientDuMoismm" existe'
'
' conversion du 1er caractère du mois actuel en majuscule
Dim m1, m2, mm, path1, path2, dossier, fichiers, fso, f1, fso1, f2, fichier, folder
m1 = DatePart("m", Date)
m2 = Array("", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre")
mm = m2(m1)
mois = UCase(Left(mm, 1)) & Mid(mm, 2)
'msgbox "mois windows: " & mm &vbCrLf&"mois modifié : " & mois
' vérification des répertoires
path1 = "d:\ClientsDe" & Year(Date) & ""
path2 = path1 & "ClientDuMois" & mois & ""
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path1)
If Not fso.FolderExists(path2) Then
Set g = fso.CreateFolder(path2)
' msgBox "Création du répertoire " & path2 & " effectuée" &vbCrLf&vbCrLf& "Copie des fichiers du répertoire " & path1 &vbCrLf& "vers " & path2 & " effectuée",vbInformation
End If
'****ici je veux lire les répertoires contenus dans path1
For Each folder In f.folders
Set g = fso.GetFolder(path1 & folder)
'*****ici trouver les noms des fichier pour chaque répertoire
For Each fichier In g.Files
' à écrire dans une table (à venir0
Debug.Print path1 & folder & "" & fichier.Name
Next
Next
Set fso = Nothing
End Sub
----------------------
Sub OuvrirExplorer()
Dim wshShell
'Set wshShell = Application.CreateObject("WScript.Shell")
'Dim xlApp As Object ' Declare variable to hold the reference.
cs_jeanmarc
Messages postés34Date d'inscriptionmardi 18 juin 2002StatutMembreDernière intervention22 novembre 2005 27 oct. 2005 à 17:04
' Test si path "ClientDuMoismm" existe'
'
' conversion du 1er caractère du mois actuel en majuscule
Dim m1, m2, mm, path1, path2, dossier, fichiers
Dim fso, f1, fichier, Subfichier, Resultat
m1 = DatePart("m", Date)
m2 = Array("","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre")
mm = m2(m1)
'msgbox mm
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path1)
If Not fso.FolderExists(path2) Then
Set f = fso.CreateFolder(path2)
Else
End if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'lecture des répertoires contenus dans path1
For Each Subfichier in f.SubFolders
' msgbox "vérification du nom du répertoire traité: " & Subfichier
'lecture des fichiers contenus les sous-répertoires de path1
set f1 = Subfichier.Files
For Each fichier in f1
Resultat = Resultat & vbcrlf & vbcrlf & fichier
Next
Next
'msgBox Resultat
Dim wshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Verif = WshShell.Popup(Resultat & vbcrlf & vbcrlf, 20, "Le répertoire " & Path1 & " contient les sous-répertoires et fichiers suivants: ")