1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| '## necessite la référence Microsoft Scripting Runtime
Sub test()
Dim oFSO As New Scripting.FileSystemObject
'supprime le fichier si celui ci existe déja
If oFSO.FileExists(ThisWorkbook.Path & "\fini.txt") Then
oFSO.DeleteFile ThisWorkbook.Path & "\fini.txt"
End If
' crée le fichier .bat
Open ThisWorkbook.Path & "\test.bat" For Output As #1
Print #1, Left([path], 2)
Print #1, "cd " & [path]
Print #1, "execute un truc long"
Print #1, Left(ThisWorkbook.Path, 2)
Print #1, "cd " & ThisWorkbook.Path
Print #1, "ECHO fini >> fini.txt"
Close #1
Shell ThisWorkbook.Path & "\test.bat", vbMaximizedFocus
While Not oFSO.FileExists(ThisWorkbook.Path & "\fini.txt")
DoEvents
Wend
oFSO.DeleteFile ThisWorkbook.Path & "\fini.txt"
oFSO.DeleteFile ThisWorkbook.Path & "\test.bat"
End Sub |
Partager