Bonjour à toutes et à tous,
Je souhaiterai obtenir votre aide sur mon problème :
Je dois réaliser une application VBA me permettant de sélectionner des fichiers et faire une copie du fichier sélection selon des conditions
Le départ du Code fonctionne très bien, une boîte de dialogue s'ouvre, je sélectionne le fichier , mais la copie ne s'effectue pas.
Je vous joins mon code
Private Sub CommandButton1_Click()
Dim objFSO As Object
Dim i As Byte
ChDrive (ThisWorkbook.Path)
ChDir (ThisWorkbook.Path & "\")
fichs = Application.GetOpenFilename(MultiSelect:=True)
If IsArray(fichs) = False Then Exit Sub
nbf = UBound(fichs)
For n = 1 To nbf
nom = nom & "-" & fichs(n)
Next
Me.ch9 = nom
Me.ch1 = Right(nom, Len(nom) - InStrRev(nom, "\"))
Me.ch11 = Format(FileDateTime(fichs(1)), "dd/mm/yyyy")
Dim DosDestination1 As String, DosDestination2 As String, DosDestination3 As String, DosDestination4 As String
DosDestination1 = ThisWorkbook.Path & "\DOS_NOTES\"
DosDestination2 = ThisWorkbook.Path & "\DOS_INSTRUCTIONS\"
DosDestination3 = ThisWorkbook.Path & "\DOS_PROCEDURES\"
DosDestination3 = ThisWorkbook.Path & "\DOS_CAS_ESPACES\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Me.ch6.Value = "DOS_NOTES" Then
objFSO.CopyFile fichs.SelectedItems(i), DosDestination1
End If
If Me.ch6.Value = "DOS_INSTRUCTIONS" Then
objFSO.CopyFile fichs.SelectedItems(i), DosDestination2
End If
If Me.ch6.Value = "DOS_PROCEDURES" Then
objFSO.CopyFile fichs.SelectedItems(i), DosDestination3
End If
If Me.ch6.Value = "DOS_CAS_ESPACES" Then
objFSO.CopyFile fichs.SelectedItems(i), DosDestination4
End If
End Sub
Merci d'avance