Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save As Existing Filename

Status
Not open for further replies.

GrahamUNC

Programmer
Mar 30, 2001
14
US
Hello all,

I am using the built in Save As dialog box to get the name for a text file I am going to write out.

However, I want to check to see if the filename already exists in the directory the user wants to save the file to. If the file already exists then I would like a message box to pop-up to ask the user if he would like to overwrite the existing file.

The message box is not the problem, I just need to know how to check the inputted file name versus the file names in the current directory.

Any suggestions?

Thanks in advance.
 
Take a look at the Dir function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How does this work for you?
Code:
Function CheckFileExist(filespec) As Boolean
    Dim fs
    Set fs = CreateObject("Scripting.FileSystemObject")
    CheckFileExist = fs.FileExists(filespec)
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top