Problem with 'scripting.filesystemobject' in ACCESS2K
3 réponses
PW
Sub essai()
Set fs = CreateObject("Scripting.FileSystemObject")
'Count the files in the folder.
Set f = fs.GetFolder(strSourcePath) '--------> C'est ici qu'est l'erreur
'Check to see if the folder is empty.
'If so, exit the function.
If f.Files.Count = 0 Then Exit Sub
'Create in the current folder a subfolder
'to place the converted files.
fs.CreateFolder (strSourcePath & "temp-2k")
End Sub
La routine qui précède me donne l'erreur suivante :
Erreur d'exécution '91':
Variable objet ou variable de bloc With non définie.
En fait la variable objet 'fs' reste NOTHING comme si l'objet refusait de se
créer.
Pouvez-vous me donner un piste pour l'explication ?
J'ai bien ajouté Microsoft Scripting Runtime dans les références du Visual
Basic, mais est-ce bien cette référence qui est la bonne ?
'Count the files in the folder. Set f = fs.GetFolder(strSourcePath) '--------> C'est ici qu'est l'erreur
Et le strSourcePath, il vient d'où ?
--
------------------------------ Francis (remplacer .nospam par .net dans mon adresse pour me répondre directement)
"Quand tout baigne, il y a forcément quelque chose qui va couler"
scraper
Bonjour PW, dans le message news:42eb5f65$0$925$ tu disais :
[...]
légèrement modifié, et en respectant globalement ton code, ça fonctionne parfaitement ici :
'---8<-------
Sub essai(strSourcePath as String)
Dim fs As Object Dim f As Object
Set fs = CreateObject("Scripting.FileSystemObject")
'Count the files in the folder. Set f = fs.GetFolder(strSourcePath) MsgBox f.Files.Count ' => renvoie un message d'info du nombre de fichiers 'Check to see if the folder is empty. 'If so, exit the function. If f.Files.Count = 0 Then Exit Sub 'Create in the current folder a subfolder 'to place the converted files. fs.CreateFolder (strSourcePath & "temp-2k")
End Sub
Private Sub Form_Load() 'par exemple, ou à tout autre endroit ...
Bonjour PW, dans le message
news:42eb5f65$0$925$8fcfb975@news.wanadoo.fr
tu disais :
[...]
légèrement modifié, et en respectant globalement ton code, ça fonctionne
parfaitement ici :
'---8<-------
Sub essai(strSourcePath as String)
Dim fs As Object
Dim f As Object
Set fs = CreateObject("Scripting.FileSystemObject")
'Count the files in the folder.
Set f = fs.GetFolder(strSourcePath)
MsgBox f.Files.Count ' => renvoie un message d'info du nombre de
fichiers
'Check to see if the folder is empty.
'If so, exit the function.
If f.Files.Count = 0 Then Exit Sub
'Create in the current folder a subfolder
'to place the converted files.
fs.CreateFolder (strSourcePath & "temp-2k")
End Sub
Private Sub Form_Load() 'par exemple, ou à tout autre endroit ...
essai "C:Windows"
End Sub
--
Adresse invalide
Merci de répondre sur le forum ...
http://scraper.chez.tiscali.fr
Bonjour PW, dans le message news:42eb5f65$0$925$ tu disais :
[...]
légèrement modifié, et en respectant globalement ton code, ça fonctionne parfaitement ici :
'---8<-------
Sub essai(strSourcePath as String)
Dim fs As Object Dim f As Object
Set fs = CreateObject("Scripting.FileSystemObject")
'Count the files in the folder. Set f = fs.GetFolder(strSourcePath) MsgBox f.Files.Count ' => renvoie un message d'info du nombre de fichiers 'Check to see if the folder is empty. 'If so, exit the function. If f.Files.Count = 0 Then Exit Sub 'Create in the current folder a subfolder 'to place the converted files. fs.CreateFolder (strSourcePath & "temp-2k")
End Sub
Private Sub Form_Load() 'par exemple, ou à tout autre endroit ...