Option Explicit Const PathSave = "C:\TEMP\Sauve" Dim objFso Set objFso = CreateObject("Scripting.FileSystemObject") CheckFileSave inputBox("Fichier à restaurer",,"MyFile.txt") Set objFso = Nothing '##################################################### Function CheckFileSave(ArgFile) If objFso.FileExists(PathSave & "" & ArgFile) Then Dim objRootFolder Set objRootFolder = objFso.GetFolder(Left(PathSave, InStr(PathSave, ""))) SearchFile objRootFolder, ArgFile Set objRootFolder = Nothing Else MsgBox "Fichier non sauvegardé" End If End Function '##################################################### Sub SearchFile(ArgFolder, ArgFile) On Error Resume Next Dim objFile, objFolder For Each objFile In ArgFolder.Files If objFile.Name = ArgFile And objFile.ParentFolder <> PathSave Then objFso.CopyFile PathSave & "" & ArgFile, objFile.Path, True msgbox "Fichier restauré: " & objFile.Path Exit Sub End If Next For Each objFolder In ArgFolder.SubFolders SearchFile objFolder, ArgFile Next End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionTxtUrl1 = "F:\SCRIPTS\Fichiers\Exemple.txt" TxtUrl2 = "F:\SCRIPTS\TEST" TxtUrl2 = TxtUrl2 & Mid(TxtUrl1, InstrRev(TxtUrl1, "") + 1) MsgBox TxtUrl2