Problème copie de fichiers

fgiuliano Messages postés 24 Date d'inscription mercredi 16 février 2005 Statut Membre Dernière intervention 17 avril 2008 - 16 févr. 2005 à 10:14
cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 - 16 févr. 2005 à 12:24
Boujour à tous,
j'ai un petit problème lié à la copie de fichiers dans un dossier. Lorsque j'execute le code, il s'interrompt et affiche un message d'erreur "Permission refusée" alors que lorsque je le fais manuellement, il n'y a aucun problème. Est-ce que qqn pourrait me venir en aide?
Voilà le code:

--------------------------------------------------------------------------------------------
Private Sub Copier_Fichiers()
Dim fs, rs As DAO.Recordset, Path As String, Lien As String

Set rs = CurrentDb.OpenRecordset("FG Journal Filtré", dbOpenDynaset)
Set fs = CreateObject("Scripting.FileSystemObject")

With rs

.MoveFirst
Do While Not .EOF


If Not IsNull(rs![Référence 1]) Then
Path = HyperlinkPart(![Référence 1], acAddress)
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
End If


If Not IsNull(rs![Référence 2]) Then
Path = HyperlinkPart(![Référence 2], acAddress)
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
End If


If Not IsNull(rs![Référence 3]) Then
Path = HyperlinkPart(![Référence 3], acAddress)
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
End If


If Not IsNull(rs![Référence 4]) Then
Path = HyperlinkPart(![Référence 4], acAddress)
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
End If


If Not IsNull(rs![Référence 5]) Then
Path = HyperlinkPart(![Référence 5], acAddress)
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
End If


If Not IsNull(rs![Référence 6]) Then
Path = HyperlinkPart(![Référence 6], acAddress)
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
End If


.MoveNext
Loop
End With


End Sub
--------------------------------------------------------------------------------------------

Merci

5 réponses

cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 9
16 févr. 2005 à 10:26
ou est ce que ca plante ?

It@li@
0
fgiuliano Messages postés 24 Date d'inscription mercredi 16 février 2005 Statut Membre Dernière intervention 17 avril 2008
16 févr. 2005 à 10:30
Au moment où il effectue la commande:
fs.CopyFile Path, "c:\ittang\Temp\Fichiers"
et alors il affiche un message d'erreur.
0
cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 9
16 févr. 2005 à 11:19
Et Avec :

fs.CopyFile Path, "c:\ittang\Temp\Fichiers" & ""

It@li@
0
fgiuliano Messages postés 24 Date d'inscription mercredi 16 février 2005 Statut Membre Dernière intervention 17 avril 2008
16 févr. 2005 à 11:47
Alors j'ai essayé et ça marche pour le premier passage dans la boucle mais sitôt qu'on passe une deuxième fois dans la boucle, un message d'erreur s'affiche:
Fichier introuvable
...
Je comprends pas vu qu'il fait exactement la même chose qu'au premier passage...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 9
16 févr. 2005 à 12:24
Verifie bien que c'est le Bon Ordre : object.CopyFile source, destination
et que la Source contient "\*.*" à la fin par exemple

Set FSys = CreateObject("Scripting.FileSystemObject")


Set Db = OpenDatabase("C:\TaBase.mdb")
Set Req = Db.OpenRecordset("SELECT * FROM [FG Journal Filtré]")
If Req.Recordcount <> 0 Then
Do Until Req.EOF
If Not IsNull(Req("Référence 1")) Then
FSys.CopyFile Req("Référence 1"), "c:\ittang\Temp\Fichiers"
End If
If Not IsNull(Req("Référence 2")) Then
FSys.CopyFile Req("Référence 2"), "c:\ittang\Temp\Fichiers"
End If
If Not IsNull(Req("Référence 3")) Then
FSys.CopyFile Req("Référence 3"), "c:\ittang\Temp\Fichiers"
End If
If Not IsNull(Req("Référence 4")) Then
FSys.CopyFile Req("Référence 4"), "c:\ittang\Temp\Fichiers"
End If
If Not IsNull(Req("Référence 5")) Then
FSys.CopyFile Req("Référence 5"), "c:\ittang\Temp\Fichiers"
End If
If Not IsNull(Req("Référence 6")) Then
FSys.CopyFile Req("Référence 6"), "c:\ittang\Temp\Fichiers"
End If
Req.Movenext
Loop
End If
Set Req = Nothing
Set Db = Nothing

It@li@
0
Rejoignez-nous