LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default 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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Exists Formula El Bee Excel Worksheet Functions 4 November 9th 06 03:45 PM
Determine if a File Exists Connie Excel Discussion (Misc queries) 1 November 8th 06 09:11 AM
File Exists Mike McLellan Excel Discussion (Misc queries) 2 May 4th 06 09:20 AM
the file already exists - do you want to replace the existing file? Paul James[_3_] Excel Programming 4 December 12th 03 02:50 AM
File|Close w/Save fires Workbook_Open twice Mike Preston Excel Programming 6 August 28th 03 10:54 PM


All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"