CleanFilename

Cleans file name from invalid unexpected characters that Windows refuses.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function CleanFilename(FileN, Optional Replacewith = "")
    ' Cleans filename from non-supported characters
    Rett = FileN
    Rett = Replace(Rett, " <", Replacewith)
    Rett = Replace(Rett, " >", Replacewith)
    Rett = Replace(Rett, ":", Replacewith)
    Rett = Replace(Rett, Chr(34), Replacewith)
    Rett = Replace(Rett, "/", Replacewith)
    Rett = Replace(Rett, "\", Replacewith)
    Rett = Replace(Rett, "|", Replacewith)
    Rett = Replace(Rett, "?", Replacewith)
    Rett = Replace(Rett, "*", Replacewith)
    ' Rett = Replace(Rett, "", "")
   
    CleanFilename = Rett
End Function

FileN, Optional Replacewith = ""

Views 86

Downloads 44

CodeID
DB ID

ANmarAmdeen
604
Attachments
Revisions

v1.0

Tuesday
February
22
2022