LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Routine for checking if file exists

several ways
you could use the
Kill
command to kill the file first
and then save it so that there is no file by that name
you will get an error on the Kill command if the file does not exist, but
you can use
On error resume next
to skip the error. Look up in help index on the KILL method.
Warning. This will permantly delete any file you use it on without asking,
and can delete entire folders!

"Centurion" wrote:

Hello,
I am using Excel 97, and have written (by recording keystrokes)
a macro that does several things and finishes off by saving the file.
However if the saved file already exists it stops the macro and prompts
user if it's ok to overwrite the file.

I would like to........

1) how do I test (within VBA) to see if the file exists.

2) If the file does exist, then overwrite without prompt.
Or alternately, save file and incrementally add '1'
to the end of the subsequent file.

Example
File-01
File-02
File-03


Thanks in anticipation.

--
Centurion



 
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
Checking to see if a file exists. JHB Excel Discussion (Misc queries) 3 August 5th 09 03:11 PM
Checking if Sheet Exists? [email protected] Excel Discussion (Misc queries) 5 September 1st 06 03:27 PM
Automating a data checking routine Tony Excel Programming 0 November 12th 04 10:03 AM
Checking if file exists in VBA NADavies Excel Programming 3 October 23rd 03 02:16 PM
Checking 2 c if workbook exists DavidMc Excel Programming 4 September 5th 03 07:34 PM


All times are GMT +1. The time now is 07:35 AM.

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"