If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Valid Filename

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-06, 03:00
michaeldavid michaeldavid is offline
Registered User
 
Join Date: Dec 2004
Posts: 35
Valid Filename

I am putting together an tool that will allow users to save certain sheets in a book to another file and I want to let the user decide the name of the file.

I have the path part of this worked out, but need help on the filename.

Is there a quick method of finding out whether a filename will be OK.

For example I wnt to ensure that they have not used a full stop (Because I will add the ".xls" and backslases are also a pain because they becaome part of the path.

Is there a ValidFilename function somewhere or will I have to write one and loop thruough all the characters ensuring that none of the above are used.

Thanks
Mike
Reply With Quote
  #2 (permalink)  
Old 07-28-06, 12:12
spikey_richie spikey_richie is offline
Registered User
 
Join Date: Jun 2006
Location: Colton, CA
Posts: 26
You could use Right() and check the last 4 chars of the string rather than using mid() to check every char...
__________________
Geek it till it mHz
Reply With Quote
  #3 (permalink)  
Old 07-29-06, 13:09
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
Mike,

if your not using the built-in GetSaveAsFilename dialog to get the user input you should consider using that. It allows you to define the file type list and you can change the current directory prior to displaying it. See the MS Excel VB Help on this for the GetSaveAsFilename Method.

To get only a path from a full path and file name string, Use a loop with the 'Mid' function to check each charter in the full path working backwords until you get a "\" backslash. Then use 'Left' with the loop count to get only the path less the file name.

You can use the 'Dir()' function to check for a valid path or path and file. using the getsaveasfilename dialog will eliminate many problems of bad user input.
__________________
~

Bill
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On