Peux-tu essayer avec ce nouveau code :
Sub test()
Dim Src$, Dest$, strCurrentFile$
Dim arrSubFoldersSrc
if dir(Userform1.textbox1.value, vbdirectory) = "" then msgbox "Source inexistante", vbcritical: exit sub
if dir(Userform1.textbox2.value, vbdirectory) = "" then msgbox "Destination inexistante", vbcritical: exit sub
Src = Userform1.textbox1.value & "\"
Dest = Userform1.textbox2.value & "\"
'TABLEAU CONTENANT LES SOUS-DOSSIERS
arrSubFoldersSrc = ListeDossiers(Src)
'PARCOURT CHAQUE FICHIER DE CHAQUE REP SOURCE ET COPIE DANS REP DESTINATION
For i = LBound(arrSubFoldersSrc) To UBound(arrSubFoldersSrc)
strCurrentFile = Dir(arrSubFoldersSrc(i) & "*.docx")
While strCurrentFile <> ""
FileCopy arrSubFoldersSrc(i) & strCurrentFile, Dest & strCurrentFile
strCurrentFile = Dir
Wend
Next i
End Sub
Function ListeDossiers(strRepertoire$)
Dim strDossier$, n&, temp()
strDossier = Dir(strRepertoire, vbDirectory)
While strDossier <> ""
If Not strDossier Like "*.*" Then
ReDim Preserve temp(n)
temp(n) = strRepertoire & strDossier & "\"
n = n + 1
End If
strDossier = Dir
Wend
ListeDossiers = temp
End Function
A priori le problème ne vient pas du fichier. Qu'y avait-il dans tes textbox ? Cette fois on teste l'existence. Il faut que les dossiers existent et contiennent des dossiers...
Pour les essais, tu peux dans un premier temps mettre les chemins en dur...
Il faudra peut-être adapter le nom de l'userform que j'ai rajouté cette fois-ci
Cdlt,