fgiuliano
Messages postés24Date d'inscriptionmercredi 16 février 2005StatutMembreDernière intervention17 avril 2008
-
16 févr. 2005 à 10:14
cs_ITALIA
Messages postés2169Date d'inscriptionvendredi 20 avril 2001StatutMembreDernière intervention30 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
--------------------------------------------------------------------------------------------
fgiuliano
Messages postés24Date d'inscriptionmercredi 16 février 2005StatutMembreDernière intervention17 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...
Vous n’avez pas trouvé la réponse que vous recherchez ?
cs_ITALIA
Messages postés2169Date d'inscriptionvendredi 20 avril 2001StatutMembreDernière intervention30 juin 20099 16 févr. 2005 à 12:24
Verifie bien que c'est le Bon Ordre : object.CopyFilesource, 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