PDA

View Full Version : [SOLVED:] Restrict characters



AJS
10-04-2004, 10:32 PM
Hello Again,

I have set up my spreadsheet to automatically generate filenames based on the text in a number of cells. Is there any way to restrict text entry / function to check text to ensure that only legal filename characters are used? (ie, none of the following: / \ : [ ] < > * ?)

Thanks, Aaron.

Jacob Hilderbrand
10-04-2004, 10:46 PM
If you are using a userform textbox you can restrict the keys used. Otherwise you can just remove the illegal characters.



Dim FileName As String
Dim y As Long
Dim TempChar As String
Dim SaveName As String

FileName = InputBox("What do you want the file name to be?")
For y = 1 To Len(FileName)
TempChar = Mid(FileName, y, 1)
Select Case TempChar
Case Is = "/", "\", "*", "?", """", "<", ">", "|", ":"
Case Else
SaveName = SaveName & TempChar
End Select
Next y

AJS
10-04-2004, 11:01 PM
Thanks again!

Jacob Hilderbrand
10-04-2004, 11:11 PM
You're Welcome

Take Care