Function to create a Legal Filename from any String:
Return to List
Public Function MakeIntoLegalFileName(ByVal FileName As String) As String
Dim I As Integer
Dim S As String
I = 1
Do While I <= Len(FileName)
S = Mid(FileName, I, 1)
If S = "\" Or S = "/" Or S = ":" Or S = "*" Or S = "?" Or S = "<" Or _
S = ">" Or S = "|" Or S = Chr(34) Then
If I > 1 Then
FileName = Left(FileName, I - 1) & Right(FileName, Len(FileName) - I)
Else
FileName = Right(FileName, Len(FileName) - 1)
I = I - 1
End If
End If
I = I + 1
Loop
MakeIntoLegalFileName = FileName
End Function