maleodillet
New Member
- Joined
- Feb 15, 2018
- Messages
- 12
Hi Gurus,
I am using VBA to generarte a .TXT file that gets picked up by a SAP process chain. The Code works well, the problem I have is that I have to be able to delete the file once I am done running the process chain but I am being unsuccessful.
So far I'm just trying to put together the routine that I would later insert into my main code but is is not working for me. What I am trying to achieve is to loop the routine to delete all the .TXT files sitting in the folder path, the code as follows;
Public Sub KillPromtFile()
Dim TxtFile As String
Dim FileFolder As String
Dim PathFolderl As String
TxtFile = Environ$("USERPROFILE") & "\Desktop\*.TXT"
FileFolder = Dir$(Environ$("USERPROFILE") & "\Desktop\*.TXT")
PathFolder = Environ$("USERPROFILE") & "\Desktop"
Do While FileFolder <> ""
Kill PathFl & FileFolder
FileFolder = Dir$(Environ$("USERPROFILE") & "\Desktop\*.TXT")
Loop
End Sub
I am not a VBA ninja so please excuse the extra declared variables...any help would be deeply appreciate it. Thanks in Advance
I am using VBA to generarte a .TXT file that gets picked up by a SAP process chain. The Code works well, the problem I have is that I have to be able to delete the file once I am done running the process chain but I am being unsuccessful.
So far I'm just trying to put together the routine that I would later insert into my main code but is is not working for me. What I am trying to achieve is to loop the routine to delete all the .TXT files sitting in the folder path, the code as follows;
Public Sub KillPromtFile()
Dim TxtFile As String
Dim FileFolder As String
Dim PathFolderl As String
TxtFile = Environ$("USERPROFILE") & "\Desktop\*.TXT"
FileFolder = Dir$(Environ$("USERPROFILE") & "\Desktop\*.TXT")
PathFolder = Environ$("USERPROFILE") & "\Desktop"
Do While FileFolder <> ""
Kill PathFl & FileFolder
FileFolder = Dir$(Environ$("USERPROFILE") & "\Desktop\*.TXT")
Loop
End Sub
I am not a VBA ninja so please excuse the extra declared variables...any help would be deeply appreciate it. Thanks in Advance