Asked by duncanb7
at 2024-10-08 06:37:48
Point:250 Replies:5 POST_ID:828373USER_ID:11059
Topic:
Visual Basic Programming;;
How to check the directy is empty or not ? I get the following code supposed that should be worked
but the if statement is alway false so I can't go to run the kill statement to delete all file if
directory is not empty.
Please advise anymistake
duncan
Code:
Sub killallfile()
Dim wkdir As String
wkdir = ActiveWorkbook.Path
wkdir = wkdir & "work emp"
Debug.Print wkdir
If Dir(wkdir, vbDirectory) <> vbNullString Then
Kill (wkdir & "Log*.*")
End If
End Sub
but the if statement is alway false so I can't go to run the kill statement to delete all file if
directory is not empty.
Please advise anymistake
duncan
Code:
Sub killallfile()
Dim wkdir As String
wkdir = ActiveWorkbook.Path
wkdir = wkdir & "work emp"
Debug.Print wkdir
If Dir(wkdir, vbDirectory) <> vbNullString Then
Kill (wkdir & "Log*.*")
End If
End Sub