(Solved) – VBA can’t kill the files with cyrillic names


I need to delete all the files in the folder.

The code runs well when file names consist of the latin letters.

It returns runtime error 52 (Bad file name or number) when any of the files contain cyrillic letters.

Surprisingly, it worked well even with cyrillic letters on my old PC.

Sub Kill1()

    Dim aFile As String
    aFile = "C:UsersbeloseDownloadstemp*.*"
    If Len(Dir$(aFile)) > 0 Then
        Kill aFile
    End If

End Sub

What could be the matter?

Leave a Reply

Your email address will not be published. Required fields are marked *