Hi all,
I have a code in my macro to kill all existing .tmp files. This code works fine when it is used in a directory with less files, however, when I use it in a directory with, lets say, more than 20 files then it does not execute the kill function. When I go through my code with f8, then it works fine and kills all the .tmp files. Does anyone know what the problem is? This is the code:
*Without stepping through the code with f8, the variable WTempDir1 gives a value with the whole path like J:\Kwaliteit Helmond\.... However, when I step through the code with f8, it gives a value like 26KP949.tmp, so it finds the .tmp file and then it works.
I have a code in my macro to kill all existing .tmp files. This code works fine when it is used in a directory with less files, however, when I use it in a directory with, lets say, more than 20 files then it does not execute the kill function. When I go through my code with f8, then it works fine and kills all the .tmp files. Does anyone know what the problem is? This is the code:
*Without stepping through the code with f8, the variable WTempDir1 gives a value with the whole path like J:\Kwaliteit Helmond\.... However, when I step through the code with f8, it gives a value like 26KP949.tmp, so it finds the .tmp file and then it works.
Code:
WTempDir1 = Dir("J:\Kwaliteit Helmond\FINAL INSPECTION REPORTS\" & Year & "\" & Matnr & "\*.tmp")
Stop
If WTempDir1 = "" Then
'Do nothing
Else
DoEvents
WTempDir1 = "J:\Kwaliteit Helmond\FINAL INSPECTION REPORTS\" & Year & "\" & Matnr & "\*.tmp"
Kill WTempDir1
On Error GoTo 0
End If