vbCommon – illegal filename chars

' -- remove illegal filename characters - note VBS' dim is different than VBA's

' ─────────────
Function stripBadFileChars(somestring)
dim badchar, xyz 'As String in vba - not vbs

badchar = ":;\|/*?" & chr(34) & chr(26) & vbCrLf & vbTab

for xyz = 1 to len(badchar) 
   somestring = StripCharsFrom(somestring, mid(badchar,xyz,1), "_")
   somestring = replace(somestring, "__", "_")
next ' xyz
   somestring = replace(somestring, "__", "_")

   stripBadFileChars = somestring

End Function ' stripBadFilChars

' ─────────────

Leave a Reply

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