View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Difficulty restricting characters

I'd go with Franz's suggestion; let the OS decide if the filename is valid
or not.

On Error resume next
WB.SaveAs "C:hhhh/\\:::tt.txt.txt.xls"
If Err.number0 then
'deal with the problem

By the way a file name of MyExcelFile.txt.xls is a valid name

NickHK

"kartune85" wrote
in message ...

With the SaveAs dialog, I still can't restrict certain characters. I've
made the form for end-users so I have to try and make it easy to use
and idi0t-proof.

I ended up using:

If InStr(1,TextBox2.Text,".") 0 then
MsgBox "Invalid characters, please re-enter."
cancel = true
Else...

The only problem is that I repeated InStr(...) for each individual
character and added them up in a variable. (SearchStr = InStr(...".") +
InStr(..."/")...)

Thanks anyway, but if anyone knows an easier way, I'm open for
suggestions.

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile:

http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=569743