File Exists Killing Workbook_Open()
I have a little code that saves the current file as a
user input name as soon as the file is opened. I am
trying to figure out how to keep the code from breaking
when the user chooses a filename that exists.
The following code was suggested:
fname = Application.InputBox( _
Prompt:="Please enter file name",
Title:="File name", Type:=2)
Do Until Dir(fname) = ""
If fname = "False" Then Exit Sub 'user clicked
Cancel
fname = Application.InputBox(Prompt:="FileName
Exists Please Try Again.", Title:="File Exists",
Type:=2)
Loop
ThisWorkbook.SaveAs Filename:=fname
I haven't been able to get this to work. I am not sure
if I am doing something wrong or not.
Any help with a solution is greatly appreciated.
|